ASP.NET MVC web app that exposes "friendly" URLs:
http://somesite.com/friendlyurl
...which are rewritten (not redirected) to ASP.NET MVC-style URLs under the hood:
http://somesite.com/Controller/Action
The user never actually sees any ASP.NET MVC style URLS. If he requests one, we hard 404 it. ASP.NET MVC is (in this app) an implementation detail, not a fundamental interface.
My question: how do you examine an arbitrary incoming URL and determine whether or not that URL matches a defined ASP.NET MVC path?
For extra credit: how do you do it from inside an ASP.NET-style IHttpModul开发者_运维技巧e, where you're getting invoked upstream from the ASP.NET MVC runtime?
Thanks!
why do you have the "hard" urls in the first place then? just change your routing, it seems kind of odd to rewrite something you have complete control over.
If you can't, you probably want something along these lines
Response.StatusCode = (int)HttpStatusCode.NotFound;
return View("NotFound");
精彩评论