Eric Andres
Eric Andres

Reputation: 3417

Problems with ASP.NET MVC site as an application in IIS

I've got an MVC project that I just installed as an application on an existing IIS Site. When testing, routing works just fine because it's running at the root of localhost, but when I deploy it as an application routing gets messed up (it's trying to route any methods to http://foo.com/search instead of http://foo.com/bar/search). I know this should be a fairly simple thing to fix, I just can't seem to come up with the correct wording that google seems to like.
FWIW, I tried doing the following, but it started throwing 403 errors:

routes.MapRoute(
            "Default", // Route name
            "bar/{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

Originally that URL was "{controller}/{action}/{id}" instead of "site/...".

Any ideas?

Upvotes: 0

Views: 71

Answers (2)

Evan Layman
Evan Layman

Reputation: 3721

Make sure you are calling Url.Content("~/") instead of just "~/" in your get/post calls.

I had this problem on some of my mvc projects before so I figured that was what was happening.

Good luck!

(If it's not okay to post my comment as an answer I will remove this)

Upvotes: 1

Muthu
Muthu

Reputation: 2685

I think you are trying to separate some modules into some other sub-folder structure. Have you tried using Areas?

It is not easy to just use an existing url to re-route.

Instead try a Mouse Right click on your VS 2010 project and add an Area. All the controllers and views which come under the area will fall into a subfolder. For example I have a url which is like http://localhost:4000/admin/manageuser/add

Upvotes: 0

Related Questions