I am trying to use IIS for debugging ASP.NET MVC in Visual Studio. The problem is that if I choose "Use Local IIS Web server" in Visual Studio, I have to choose a virtual directory, something like http://localhost/myapp/
This is a problem because the ASP.NET MVC application is assumed to run from the root directory and the MVC would parse "myapp" as a controller, and when I run the app from Visual Studio/IIS, subsequent requests will be directed to the root anyway.
How to solve this problem? Is there a way to use the IIS website root instead of a virtual directory for Visual Studio debugging?
To create a virtual directory with IIS Manager for an ASP.NET application. In IIS Manager, expand the local computer and the Sites folder. Right-click the site or folder where you want to create the virtual directory and then click Add Virtual Directory.
To start debugging, select IIS Express (<Browser name>) or Local IIS (<Browser name>) in the toolbar, select Start Debugging from the Debug menu, or press F5. The debugger pauses at the breakpoints. If the debugger can't hit the breakpoints, see Troubleshoot debugging.
Open IIS Manager by Typing inetmgr on Start Menu or Run. Click On Sites on the Left navigation of IIS Manager. Right Click on Site where you want to Add Virtual Path and Choose Add Virtual Directory. Put the Short Name of Application/Website in Alias Field.
Yes you can run an ASP.NET MVC as the root application.
Just use IIS manager to set the home directory for the website to the your application's path.
Then make the appropriate changes in the "Web" tab of your project settings for MVC in Visual Studio.
This is assuming you have windows file permission setup correctly for IIS already.
You say that
the ASP.NET MVC application is assumed to run from the root directory and the MVC would parse "myapp" as a controller
However, it is possible to run ASP.NET MVC from a virtual directory by adding wildcard mapping as described in this article:
ASP.NET MVC on IIS 6 Walkthrough
See also this question here on stackoverflow, and the accepted answer which describes the steps followed to solve a similar problem:
ASP.NET MVC How-to use routes when application is published as SubProject of a domain?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With