MVC重定向将Web根插入URL

时间:2014-01-10 15:34:03

标签: asp.net-mvc asp.net-mvc-4

当我的MVC4网站(mywebsite.com)部署(到Amazon Web Services)并且未经过身份验证的用户点击需要身份验证的链接(例如搜索)时,它们会被重定向到

  

www.mywebsite.com/的 Web.UI_deploy /帐户/登录?RETURNURL =%2fSearch

而不是

  

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

Web.UI_deploy 是Web服务器上的Web根目录)。此问题仅在部署时发生,而不是在localhost上发生。

解决此问题的最简洁方法是什么?

1 个答案:

答案 0 :(得分:1)

web.config中的微小变化解决了问题

  

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

我删除了波浪号〜它解决了问题

  

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

我从Issue with return URL Authorize issue MVC4

得到了这个想法