Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 包含HashBang的LoginPath未正确重定向_C#_Routing_Asp.net Mvc 5 - Fatal编程技术网

C# 包含HashBang的LoginPath未正确重定向

C# 包含HashBang的LoginPath未正确重定向,c#,routing,asp.net-mvc-5,C#,Routing,Asp.net Mvc 5,我在MVC5中使用cookie身份验证,我有一个包含hashbang的登录路径,如下所示: app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/#!/Login"), Provider...etc etc }

我在MVC5中使用cookie身份验证,我有一个包含hashbang的登录路径,如下所示:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/#!/Login"),
    Provider...etc etc
}
不幸的是,当用户被重定向到此登录路径时,他们会被定向到此登录路径的转义版本,从而导致404错误,我在浏览器开发人员控制台中看到以下内容:

GET http://localhost:27431/%23%21/Login?ReturnUrl=%2Faaa%2Fbbb 404 (Not Found) 
我假设我在某个地方犯了一个基本的错误,但不确定是什么,有人能告诉我吗


谢谢,这并不理想,但创建一个虚拟的MVC控制器操作,然后重定向允许我重定向到带有“#!”的url在里面

例如,在CookieAuthenticationOptions中

LoginPath = new PathString("/LoginRedirect")
行动


[AllowAnonymous]
public ActionResult LoginRedirect(string returnUrl)
{
  return this.Redirect("/#!/Account?" + returnUrl);
}

将您的登录路径更正为。。。。LoginPath=new PathString(“/Login”)@但这不是我的登录路径,而是#/登录,如中所示,我想转到位于applicationnew PathString根目录下的SPA的/login路径(“/#!login”)…只需在PathString中删除一个额外的“/”…没有更好的方法,@Exception,MVC正在尝试重定向到LoginPath的转义版本,我需要它在将字符串发送到浏览器之前取消对字符串的浏览,这可能吗?请尝试使用System.Web.HttpUtility.UrlDecode()…然后。。。