I've created a new Route class, named SubdomainToAreaRoute, inherited from System.Web.Routing.Route, to handle subdomain.
The next implementation needed is to create a helper method to generate subdomain link.
For example:
Html.ActionLink("subdomain1", "account", "index") would generate:
http://subdomain1.example.com/account/index A series of other overloaded methods will also be implemented.
I undestand the geist of creating extension methods, which is one of the requirement to implementing these helper methods. Thus the main concern here is knowing what objects/classes to access and manipulate, and recommended algorithm to use.
There are some things that is unclear to me. For example, we register routes in the RouteTable.Routes (or simply route table), and whenever a url is requested, the url request is checked in the route table. If no url pattern matches, or if there is a matching pattern and the resource (e.g. web page) is missing, we receive a http error.
What is unclear here is in cases where specific physical path to a resource, like an image or javascript file is used for request. If these physical path url do not match the url patterns in the route table, how does an MVC application know to check for web application directory for the resource as the next step? As oppose to throwing an http error saying the resource can not be found.
This question may or may not affect my main concern here. But it is good to know if someone can explain it.
Focusing on registered routes, consider the following url route registration:
routes.Add("Home", new SubdomainToArea("", new { area = "Root", controller = "Home", action = "Index" } ) );
// route pattern 1
// intended to map to url: http://{area}.localhost.com
routes.Add("Default", new SubdomainToArea("{controller}/{action}", new { area = "Root", controller = "Home", action = "Index" } ) );
// route pattern 2
// intended to map to url: http://{area}.localhost.com/{controller}/{action}
routes.Add("Images", new SubdomainToArea("images/{*pathInfo}", new { area = "Root", controller = "Home", action = "Index" } ) );
// route pattern 3
// intended to map to url: http://{area}.localhost.com/images/{random path string}
How do I create helper methods to generate the appropriate url that matches these patterns?
I understand that extension methods for the UrlHelper class should be implemented to generate these url, and these url will be use in HtmlHelper class to generate the appropriate link tags.
In these helper methods, e.g. in the UrlHelper class, if passed a set of route values (such as controllers, action, areas and other url path details), how do we choose the appropriate route pattern that is registered in the route table, and then apply the route values to the pattern to generate the url?
How should I handle in cases where I don't specify one? What does the standard Html- Url- helper methods handle in case where no route name is not specified?
I understand the placeholder {controller}, {action} and {area} have special meaning and can be more easily identified and mapped to url pattern and so forth. How do we deal with custom placeholders we dynamically create, and use them for generating url?
I have made an asp.net mvc 3 application with an area called blog. I want to route this area to my subdomain blog.mywebsite.com. How can I achieve this?
How do I need to define my route? Do I have to configure the DNS?
Currently I just use the default area route. I can access my blog area for now at this way. mywebsite.com/blog
On my page load I want to find out the subdomain of the currently visited site, I got my [URL] into a string, now how can I use RegEx to just retreive "sub" out of the whole string? note that www may and may not be there every time.
What I want to do is take traffic that is going to shop.mywebsite.com and redirect or rewrite (I'm not sure of the terminology) the domain to be www.mywebsite.com/shop. Both shop.* and www.* are separate web applications (nopCommerce and Umbraco respectively) that don't seem to cooperate when I've tried to nest them. Both applications are in a Server 2008 R2/IIS 7.5 environment.
I've searched around stackoverflow and what I've found is a lot of answers to mapping the other direction (ie subfolder to a subdomain) but that's not what I'm looking for as far as I understand the problem.
The end goal is to combine the SEO reputation of the shop subdomain into the www subdomain. I readily admit that I might have this all backwards and am willing to try any suggestions I'm offered.
I have an app with multiple subdomains, subone.parent.com, subtwo.parent.com.
I have a logon page at parent.com/login. When a user logs in I redirect them to the proper domain based on which one they are a member of. This works fine.
FormsAuthenticationTicket ticket = new FormsAuth... string encTicket = FormsAuthentication.Encrypt(ticket); var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); cookie.Domain = subone.parent.com Repsonse.Cookies.Add(cookie)
This properly authenticates the user for subone.parent.com and not subtwo.parent.com. However I would like to do the following.
If the user goes back to parent.com, I would like to know that they are logged in and redirect them back to subone.parent.com.
Is there a best practice for accomplishing this? Or do I have to set another cookie for parent.com?
Was looking at asp.net mvc complex routing for tree path as an example of how to define a custom route handler for my MVC app. Essentially, I want to give the end user ultimate flexibility in defining the URL for any given page, so I provide them with a field in the interface to specify their own custom URL.
My custom route handler is basically a wild-card handler. It will do a lookup and if it finds a match, map it accordingly. However, if no match is found, I want it to fall back and find the next rule that matches in the global.asax. Is that possible? Or do I essentially need to code the mappings that used to exist in my global.asax into my custom route handler?
i'm new to asp.net mvc2. i'm developed one project using asp.net mvc2 and vs2010 using linq to sql server. my project like a blog posting comment,
create tickets. my problem is when user register in my blog example my blog name is "helpdesk.com". when user register in my blog with the company name example "something". after registering the user i want to create one sub domain for this user like "something.helpdesk.com"
using this url "something.helpdesk.com" how to server my view pages. i'm not getting any idea. in this concept i have no idea about routing concepts. any body know please suggest me how to create sub domain and how can i server the view pages with in subdomain.
I'm using a BlogEngine.net for my blog and I would like to create 5 different subdomains and point to different subfolders(not redirecting). For example:
I am using MVC 2.0 to create my application,my problem i s related to the routing. Actually in my application each user have required seperate subdomain,like
www.example.com/user1/ ,www.example.com/user2/ ...etc.the default domain is www.example.com.So how can i make it possible with routing in mvc.
i have tried like this, routes.Add(new Route("{id}", new RouteValueDictionary(new { controller = "User", action = "login", id = " " }), new MvcRouteHandler())); var defaults = new RouteValueDictionary( new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); routes.Add(new Route("{controller}/{action}/{id}", defaults, new MvcRouteHandler()));
But the problem is that it take deafult (www.example.com) directly to user login page.I want the default page as Home/index and when www.example.com/user1/ it will go to user login page.
I want to have a subdoman (sub.site.net).irst of all, I don't know how to copy my files to this registered subdomain. Second: I want to Redirect my whole website to a new sudomain. for example if a user types: "www.site.net" it automatically goes to "sub.site.net". is it possible? if yes, What should I change? Maybe in my master page?
I got a website [URL] and I want to redirect http://www.example.com/folder to http://folder.example.com so if folder has a page called example1.aspx [URL]
It should be called in this way:
http://folder.example.com/example1.aspx Is that possible that using IIS 7 and asp.net 4.
I am creating a social networking site and one of the requirements is to have the subdomain like URL for each user. For example, for the user1 his profile page will be user1.mysitename.com and for the user2 profile page will be user2.mysitename.com.
Can it be done using url aliasing? basically user1.mysitename.com should be www.mysitename.com/profile.aspx?username=user1
Using the VS2010 ASP.NET Development server I am unable to run or execute the website.
When browsing http://localhost:2687/TestProject/ it shows up the default.aspx page. But when accessing http://abc.localhost:2687/TestProject/ it shows a website cannot be found page.
Is there anything else to be done when setting up subdomain on localhost.
EDIT: To make this work I removed the .com and in IE-->Connections-->LAN uncheck everything. Subdomains with port works are correctly getting forwarded. Nothing else need to be configured.
I have a portal say 'portal.mysite.com'. I have another portal say 'login.mysite.com'. Could someone tell me how I could use the same login credentials to login into the subdomain?
i have website [URL] this website got capability of host multiple shop sites with in... Now issue i am facing is that when we create sub site like this [URL] its working on production server. where as the code version i am running on windows 7.
I have stuck in a situation the error is occuring on subdomain site...
to reproduce that on my local machine... don't no what to do..
Just curious if subdomains can be generated dynamically. For example say I have [URL]. In a SQL DB is a list of cities. Can these be used to generate new subdomain for each city? (ie [URL], [URL], etc.) Or do I have to create every sub domain I want manually?