Jonathan
Jonathan

Reputation: 1377

MVC redirect inserts web root into URL

When my MVC4 web site (mywebsite.com) is deployed (to Amazon Web Services) and a non-authenticated user clicks on a link requiring authentication (e.g. Search), they are redirected to

www.mywebsite.com/Web.UI_deploy/Account/Login?ReturnUrl=%2fSearch

instead of

www.mywebsite.com/Account/Login?ReturnUrl=%2fSearch

(Web.UI_deploy is the web root on the web server). This issue only occurs with deployment, not on localhost.

What is the cleanest method of resolving this?

Upvotes: 0

Views: 371

Answers (1)

Jonathan
Jonathan

Reputation: 1377

Minor change in the web.config solves the issue

Before

<authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>

I removed the tilde ~ and it solved the problem

After

<authentication mode="Forms">
      <forms loginUrl="/Account/Login" timeout="2880" />
</authentication>

I got this idea from Issue with return URL Authorize issue MVC4

Upvotes: 1

Related Questions