Blogs as Sub Domains in ASP.Net MVC - asp.net-mvc

My blog creates URLs like this:
http://localhost:55649/Blogs/MyBlog
How can I create a sub domain so that it looks like it's hosted on it's own subdomain, like this:
http://myBlog.localhost:55649/
I know I can create a sub domain to redirect to localhost:55649/Blogs/MyBlog, but I want that to be the actual domain. Is this possible?

This is possible in MVC and has been answered before here on SO
See Previous Answer
In order for DNS to work, you will need to setup a wildcard subdomain so that any subdomain request for yourdomain.com will still point to your site. IIS will also need to be configured to listen for any and all request for any subdomain for your site. I cannot answer how to do this as I do not know your hosting configuration.

Probably it is not possible by ASP.NET MVC own possibilities like routing.
You need to create two sites in IIS (one for domain and another for subdomain) pointed to the same directory with site code.
And surely it is not possible with ASP.NET Development Server.
Probably URL Rewrite module would also help you: http://www.iis.net/download/urlrewrite

Related

domain specific ASP.NET MVC5 route with IIS rewrite

I have an MVC5 web application which maps to a domain www.example.com. I'm using basic {area}/{controller}/{action} based routing in my webapp and would need to map a subdomain to a specific route.
For example:
subdomain.example.com needs to always server content from http://example.com/area/controller/action
Ofcourse the route has to work with ASP.NET MVC5 routing and also all query parameters and "hashbang" data need to be retained so that:
http://subdomain.example.com#/somethinghere?var=value redirects content from http://example.com/area/controller/action#/somethinghere?var=value
So the question is: is this achievable with IIS routing/rewriting and if so, how? Another option would be to write custom MVC5 route which binds to a domain and I would love to see someone point me to a right direction with that, too.
This will not be possible, anything after the hash is client side only and the browser will not send it back to the server. As it is not send to the server there is no way to rewrite it.
As an alternative you can consider changing your routing to use pushstate instead of hashstate

Can a subdomain website create more subdomains on the same parent domain?

I am creating a rails website which needs the ability to create subdomains, however, the admin panel which can create these subdomains needs to also be located on its own subdomain so that the parent domain is separate.
Is it possible to create subdomains from a website already on a subdomain?
Sorry if it's hard to understand, I struggled to explain it.
Thanks.
Actually you can have just one application responding to how many domains you want. Just need to user proxy_pass if you are using nginx
Check this: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

Multiple applications on the same URL/Port (IIS)

I'm developing an ASP.Net MVC application in C#, and it is hosted in an IIS server. Right now the client asked me to have a CMS on the same app url, that will be used to serve the public pages.
I have looked for ASP.Net MVC CMS apps and could not find anything that would be easily integrated with the current application, so I choose to do it by changing the server configuration.
What I need is:
Custom App:
exampleappurl.com/User
exampleappurl.com/Company
etc
CMS:
Any other URL, including "index" (exampleappurl.com)
Can I do it using any kind of Rewrite rule? Or IIS configuration? What is the best solution?
Thanks in advance!
On IIS6, there is a feature called 'host headers', that does exactly this: several websites may share the port 80, and the request goes to one of the sites its URL points to.
http://www.it-notebook.org/iis/article/understanding_host_headers.htm
http://technet.microsoft.com/en-us/library/cc753195(v=ws.10).aspx (this one is about IIS 7)

Route to subdomain

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
You will require a CNAME entry setting up that will redirect to your website. Your hosting provider will be able to help out here if you are not familiar with this.

Creating sub-domains for different cities in my ASP.NET MVC App

I'm learning .NET MVC 2 and would like to know how I could go about creating sub-domains for a list of cities that I have stored in a table. It would be nice if they were somehow created dynamically as I add cities to the table.
For Example:
seatle.mysite.com
calgary.mysite.com
orlando.mysite.com
I'd like for it to work in my local "Dev" environment (windows 7, IIS 7) as well as on my live site (shared hosting, unlimited sub-domains).
You'll have to create your subdomains on your DNS. Technically, you could program this into the Application_Start, but you really should figure out what list you will have and then just do the job to create them once.
Alternatively, see if your DNS and webhost can do wildcard domains so that *.domainname.com will go to your website.
After you do that, Maarten Balliauw's blog has an article on how to route subdomains:
http://blog.maartenballiauw.be/post/2009/05/20/ASPNET-MVC-Domain-Routing.aspx

Resources