I am setting up a test server that will be used to test multiple MVC apps as they are built and published. To keep things clean, I published my first site to a sub folder of the Default Site but would like it to be the default MVC app for the server. I
thought I could set the index page of the MVC app as the default page in the IIS server configuration but, it just loads the IIS welcome page, not my app. The server is named http://testweb
and the MVC app is located at http://testweb/app1/ so I set the default page to /app1/Home/Index.cshtml in the default document section and made it the top entry.
This is an IIS and network (DNS) support support question.
IIS has a concept of bindings where the site is bound to a domain and port. It is best to create a sub domain like test.mydomain.com on the test server and assign port 80 (HTTP) or 443 (HTTPS) so you access the site like any other site. Then the default
URL is just http://test.mydomain.com.
We did setup a subdomain and that's what created the problem; a little further explanation may be in order. The site is not actually called app1 as I originally explained, it's something a little longer and more descriptive e.g. order-system.
We setup a subdomain called ordersystem with goDaddy and have it setup on a custom port. So at the moment the URL to access it looks something like this:
ordersystem.compnayname.com:160000/Order-System/
the repetition of the words "order system" are silly so I am trying to eliminate the last part of the URL.
In IIS, there aren't any binding settings for "sub" sites, just the main site so, are you suggesting I create multiple sites instead of using the single default site?
In IIS, there aren't any binding settings for "sub" sites, just the main site so, are you suggesting I create multiple sites instead of using the single default site?
Yes...
I don't know what version of IIS you are using but you simply create an application then bind the site. If you have domain names then you can use port 80 by setting host headers (IIS 6) or just setting the binding in later versions of IIS.
The starting page in an application is usually the root default.xxx, index.xxx... but you can set that in the application configuration. Not the default but the new application you created.
It seems that you can't set the MVC page as IIS default document, the path you configure as default document should be the physical file path related to the website's root folder.
When the request comes, the IIS will check if there are files exists at the locations that you configure as IIS default document. However, in MVC you can't request the /Views/ControllerName/ActionName.cshtml directly. In asp.net, we request the domain/ControllerName/Action
and then the MVC routing will handle the request.
So the IIS Default document isn't suitable in your condition, to achieve your requirement, I think you can use the IIS URL Rewrite to rewrite
http://testweb to http://testweb/app1/Home/Index.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
1 Points
43 Posts
How to make MVC Site the default page for IIS server?
Aug 30, 2017 03:16 PM|PhillD|LINK
I am setting up a test server that will be used to test multiple MVC apps as they are built and published. To keep things clean, I published my first site to a sub folder of the Default Site but would like it to be the default MVC app for the server. I thought I could set the index page of the MVC app as the default page in the IIS server configuration but, it just loads the IIS welcome page, not my app. The server is named http://testweb and the MVC app is located at http://testweb/app1/ so I set the default page to /app1/Home/Index.cshtml in the default document section and made it the top entry.
Is there a better way to do this?
All-Star
52091 Points
23214 Posts
Re: How to make MVC Site the default page for IIS server?
Aug 30, 2017 06:03 PM|mgebhard|LINK
This is an IIS and network (DNS) support support question.
IIS has a concept of bindings where the site is bound to a domain and port. It is best to create a sub domain like test.mydomain.com on the test server and assign port 80 (HTTP) or 443 (HTTPS) so you access the site like any other site. Then the default URL is just http://test.mydomain.com.
Without the domain, simply access the site by http://testweb/appname.
See IIS support for more information.
https://support.microsoft.com/en-us/help/323972/how-to-set-up-your-first-iis-web-site
https://technet.microsoft.com/en-us/library/cc772350(v=ws.10).aspx
https://docs.microsoft.com/en-us/iis/application-frameworks/scenario-build-an-aspnet-website-on-iis/configure-an-asp-net-website-on-iis
Member
1 Points
43 Posts
Re: How to make MVC Site the default page for IIS server?
Aug 30, 2017 07:47 PM|PhillD|LINK
Hi Again,
We did setup a subdomain and that's what created the problem; a little further explanation may be in order. The site is not actually called app1 as I originally explained, it's something a little longer and more descriptive e.g. order-system.
We setup a subdomain called ordersystem with goDaddy and have it setup on a custom port. So at the moment the URL to access it looks something like this:
ordersystem.compnayname.com:160000/Order-System/
the repetition of the words "order system" are silly so I am trying to eliminate the last part of the URL.
In IIS, there aren't any binding settings for "sub" sites, just the main site so, are you suggesting I create multiple sites instead of using the single default site?
All-Star
52091 Points
23214 Posts
Re: How to make MVC Site the default page for IIS server?
Aug 30, 2017 08:43 PM|mgebhard|LINK
Yes...
I don't know what version of IIS you are using but you simply create an application then bind the site. If you have domain names then you can use port 80 by setting host headers (IIS 6) or just setting the binding in later versions of IIS.
https://blogs.technet.microsoft.com/chrad/2010/01/24/understanding-iis-bindings-websites-virtual-directories-and-lastly-application-pools/
https://docs.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/bindings/binding
https://www.digicert.com/ssl-support/ssl-host-headers-iis-7.htm
The starting page in an application is usually the root default.xxx, index.xxx... but you can set that in the application configuration. Not the default but the new application you created.
Member
1 Points
43 Posts
Re: How to make MVC Site the default page for IIS server?
Aug 30, 2017 09:18 PM|PhillD|LINK
I'm using IIS 8.5 Unfortunately, the sys admin can't use port 80 externally because it is in use by other services on all available IP's.
Setting up a new site for each MVC app makes sense instead of creating applications under the default site.
Thanks again.
Contributor
6490 Points
2525 Posts
Re: How to make MVC Site the default page for IIS server?
Aug 31, 2017 02:23 AM|Jean Sun|LINK
Hi PhillD,
It seems that you can't set the MVC page as IIS default document, the path you configure as default document should be the physical file path related to the website's root folder.
When the request comes, the IIS will check if there are files exists at the locations that you configure as IIS default document. However, in MVC you can't request the /Views/ControllerName/ActionName.cshtml directly. In asp.net, we request the domain/ControllerName/Action and then the MVC routing will handle the request.
So the IIS Default document isn't suitable in your condition, to achieve your requirement, I think you can use the IIS URL Rewrite to rewrite http://testweb to http://testweb/app1/Home/Index.
To use the URL Rewrite, please first install the IIS URL Rewrite Extension
Then you can add the following code into your website's web.config file.
The following link shows more about how to use IIS URL Rewrite, please take it as reference.
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
Best Regards,
Jean
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.