Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.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
打开ASP.NET';s";ReturnURL";转换为绝对URL_Asp.net_Asp.net Mvc_Asp.net Mvc 3_Redirect_Forms Authentication - Fatal编程技术网

打开ASP.NET';s";ReturnURL";转换为绝对URL

打开ASP.NET';s";ReturnURL";转换为绝对URL,asp.net,asp.net-mvc,asp.net-mvc-3,redirect,forms-authentication,Asp.net,Asp.net Mvc,Asp.net Mvc 3,Redirect,Forms Authentication,我有两个安全站点: siteA.example.com siteB.example.com siteA.example.com上存在一个通用登录页。如果您未登录而访问siteB.example.com,您将被重定向到siteA.example.com。URL最终看起来如下所示: 这对我来说不起作用,因为返回的URL实际上只是将你带到siteA.example.com的主页,即使用户访问了siteB.example.com UrlHelper.GenerateUrl(null, "action

我有两个安全站点:

siteA.example.com
siteB.example.com
siteA.example.com上存在一个通用登录页。如果您未登录而访问siteB.example.com,您将被重定向到siteA.example.com。URL最终看起来如下所示:

这对我来说不起作用,因为返回的URL实际上只是将你带到siteA.example.com的主页,即使用户访问了siteB.example.com

UrlHelper.GenerateUrl(null, "action", "controller", "http", "siteA.example.com", null, new { id = "Awesome" }, routes);

是否有一种可配置的方法来修复此问题?或者我应该挂接一个全局生命周期事件来更改响应吗?

在设置returnURL的值时,您可以编写一个或使用一个。

使用UrlHelper。使用允许您设置主机名的重载,并传入sizeA.example.com

UrlHelper.GenerateUrl(null, "action", "controller", "http", "siteA.example.com", null, new { id = "Awesome" }, routes);

我发现了这个小把戏:

更改您的配置

 <forms loginUrl="http://google.com/Login?domain=http://google.fr/" />

其中google.com是您输入凭据的地方,google.fr是需要登录用户的应用程序


然后,在重定向用户之前,您只需使用参数ReturnUrl将其连接起来。

我让臭名昭著的Darin回复了我的一篇帖子?:)谢谢你的链接。我认为一个模块或事件可能是我的解决方案,但我想确保我没有忽略表单身份验证的某些内容。另外,为您在StackOverflow上提供的帮助干杯。我在MVC学习和工作的最后几个月经常发现你的帖子。可惜内容没有发布,链接已经死了。这么简单我希望我能想到它。您需要自定义登录处理程序逻辑,但我的特殊情况需要这样做(混合模式身份验证)。