I work with a server with a custom URL: http://example.com/site/ , and as you can see, I need to change the default root path ("/") of my application to prevent 404 errors. Using the module rewriting IIS with the outbound rule seems to work, with all the html links and links being correctly converted to request an internal website. The problem is that my controllers use the Redirect() or RedirectToAction() method, the internal website name is dropped, so 404 is called. This is my outgoing IIS rule:
<rewrite> <outboundRules> <rule name="Add path prefix to urls" stopProcessing="true"> <match filterByTags="A, Form, Img, Link, Script" pattern="^/(.*)" /> <action type="Rewrite" value="/site{R:0}" /> </rule> </outboundRules> </rewrite>
So, to clarify: I have http://example.com/site/ , when the redirect occurs in Account / Login, it becomes http://example.com/account/login instead of http://example.com/site/ account / login . I assume that RouteConfig needs to be tinkered with, but I do not know how, or if I can do it in IIS. My RouteConfig class has the following:
routes.MapRoute( name: "SiteRoot", url: "site/{controller}/{action}", defaults: new { controller = "Home", action = "Index" } ); routes.MapRoute( name: "Default", url: "{controller}/{action}", defaults: new { controller = "Home", action = "Index" } );
Thanks.
source share