开发者

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 co开发者_C百科rrect 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?


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)


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜