Asp – Deployment of Asp.Net MVC app on Win2k3 issue

asp.net-mvc

I’ve created an ASP.net mvc application on my windows XP machine. Now, I’m at the stage where I want to deploy my application. I’ve done some googling on how to install/configured MVC apps under IIS 5.1 and 6.0 but I’m still having issues although I’ve done everything, so I believe, by the book.

On my XP box, I’ve created a Virtual Directory and added the Application Mapping “.*” and unchecked the “Check that file exists”.

When I navigate to localhost/vince/ my page displays great! Once logged, I’m being redirected to:
localhost/vince/Transaction/Index

The view (Transaction/Index.aspx) simply displays business information…

The user, has the liberty to edit his account by clicking the MyAccount link which brings him to:
localhost/vince/Account/Index

I have a cancel button at the bottom of that view which basically brings you back to:
localhost/vince/Transaction/Index

The view source of that cancel button is this:

<input onclick="location.href='/Transaction/Index'" 
       type="button" value=" Cancel " />

The problem is when the user clicks the cancel button he is being sent to localhost/Transaction/Index

And I get a 404 page not found…Notice how the name of my virtual directory “vince” was removed.

To further my testing…I’ve decided to deploy my MVC app on Win2k3 with IIS 6.0. Created the exact same thing, Virtual Directory and added the Application Mapping, only to realize that it was doing the same thing. Now instead of creating a Virtual Directory, I created a WebSite. Oddly enough, it now works without having to change anything…does anyone know why it now works within a new WebSite as opposed to a new Virtual Directory.

Thanks

Best Answer

Your cancel button is sending the browser to /Transaction/Index. The important thing to note is the leading slash on that URL. This is sending you to the root of the site (with no virtual directory included). That's why it works on IIS 6 when you create a website - there is no virtual directory being used there.

The fix for this is to use the Routing infrastructure to generate the link for the cancel button - it sounds like you are already doing this for the other links in your application.