Reputation: 159
I have an application hosted on an Amazon server with two instances, one for test and one for production.
ie.
On server 123.456.789.123 the app instances are
- wwwroot/myappuat
- wwwroot/myappprod
So the subdomain myapp.mydomain.com DNS settings point to the server 123.456.789.123
And rewrite rules have been set for these instances, let's just look at production
<rule name="myapp.mydomain.com" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^myapp.mydomain.com$" />
</conditions>
<action type="Rewrite" url="\myappprod\{R:0}" />
</rule>
The trouble is when RedirectToAction seems to behave differently than when I was just testing on localhost in development.
For instance:
RedirectToAction("Login", "Home")
will redirect to http://myapp.mydomain.com/myappprod/Home/Login instead of the intended http://myapp.mydomain.com/Home/Login
I suspect I need to modify the routing settings in RegisterRoutes. But I don't know what to do.
Any help on this will be greatly appreciated.
Upvotes: 2
Views: 369
Reputation: 159
I found where I went wrong.
Tilda's.
For example there is a redirect from the URL authorization to the login page which was set like this:
<authentication mode="Forms">
<forms loginUrl="~/Home/Login" timeout="2880" />
</authentication>
Since the URL has been rewritten, the path still included /myappprod. Removing the tilda fixed it
<authentication mode="Forms">
<forms loginUrl="/Home/Login" timeout="2880" />
</authentication>
One extra thing while I'm on here. Make sure you use Url.Content("~/url/here")
not just "~/url/here"
. Particularly with those tildas.
Upvotes: 1
Reputation: 5569
Try putting the prefix in the RegisterRoutes method in global.asax
e.g.
routes.MapRoute(
"Default", // Route name
"myappprod/{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
Upvotes: 0