简体   繁体   English

重定向到登录页面时,asp.net/iis 不附加 ReturnUrl

[英]asp.net/iis is NOT appending a ReturnUrl when redirected to login page

Using Forms authentication in a traditional (not mvc) asp.net app, I can not get IIS or IIS-express (when debugging in VS2019) to append a ReturnUrl to the request querystring when it redirects to login.aspx. Using Forms authentication in a traditional (not mvc) asp.net app, I can not get IIS or IIS-express (when debugging in VS2019) to append a ReturnUrl to the request querystring when it redirects to login.aspx. Thus Request["ReturnUrl"] is always null.因此 Request["ReturnUrl"] 总是 null。

I've read many questions/answers over a few days regarding the Redirect not working but it's always in regards to after authentication and nobody that I've seen has had the problem where?ReturnUrl=/blah/blah/blah is not even getting appended to the url itself.几天来,我已经阅读了很多关于重定向不起作用的问题/答案,但它始终与身份验证后有关,而且我见过的没有人遇到过问题在哪里?ReturnUrl=/blah/blah/blah 甚至没有得到附加到 url 本身。

Also have read instances where users want ReturnUrl to NOT be appended which is maybe fixed by some code in Global.asax.还阅读了用户希望不附加 ReturnUrl 的实例,这可能由 Global.asax 中的某些代码修复。 Lucky them, I wish I had that problem instead of not getting the ReturnUrl in the first place!幸运的是,我希望我有这个问题,而不是一开始就没有得到 ReturnUrl!

I've tried every web.config possibility regarding the tag;我已经尝试了关于标签的所有 web.config 可能性; specifiying/not specifying loginUrl and defaultUrl;指定/不指定 loginUrl 和 defaultUrl; specifiying allow/deny and all combinations thereof I do have a Global.asax but it is empty for the Request-related methods.指定允许/拒绝及其所有组合我确实有一个 Global.asax 但它对于与请求相关的方法是空的。 I've also looked into various IIS settings to see if it is an option that it appends a returnUrl but I haven't found anything that suggests that option.我还研究了各种 IIS 设置,看看它是否是一个附加 returnUrl 的选项,但我没有找到任何暗示该选项的东西。

The latest basic entry I tried:

<authentication mode="Forms">
  <forms timeout="120" slidingExpiration="true" />
</authentication>
<authorization>
  <!--<deny users="?"/>-->
  <allow users="*"/>
</authorization>

I should also add that I am using a custom membership provider and not the default asp.net membership provider.我还应该补充一点,我使用的是自定义成员资格提供程序,而不是默认的 asp.net 成员资格提供程序。 Although not sure that would even matter in IIS appending/not appending a ReturnUrl but you never know...虽然不确定在 IIS 中附加/不附加 ReturnUrl 是否重要,但你永远不知道......

<membership defaultProvider="LegacyDBMembershipProvider">
  <providers>
    <remove name="AspNetSqlMembershipProvider"/>
    <add name="LegacyDBMembershipProvider" someothertags... />
  </providers>
</membership>

I would like to have IIS redirect me to login.aspx (as it does) but have the Url look like: http://localhost:21542/MyWeb/Login.aspx?ReturnUrl=/MyWeb/RequestedPage.aspx instead of just: http://localhost:21542/MyWeb/Login.aspx I would like to have IIS redirect me to login.aspx (as it does) but have the Url look like: http://localhost:21542/MyWeb/Login.aspx?ReturnUrl=/MyWeb/RequestedPage.aspx instead of just: http://localhost:21542/MyWeb/Login.aspx

so that after authentication I can redirect the user to the originally requested page.以便在身份验证后我可以将用户重定向到最初请求的页面。

Thanks for your time and your consideration.感谢您的时间和考虑。

Thanks Brando, wazz and all that took time to read my question.谢谢白兰度,瓦兹和所有花时间阅读我的问题的人。 Apparently it came down to the [allow users=" "/> tag itself.显然它归结为 [allow users=" "/> 标签本身。 Whether or not I had [deny users> anywhere before or after it.无论我在它之前或之后是否有 [deny users> 任何地方。 I'm not sure why if I only have [allow users=" "/> (and no deny tag) that it even still forces to the login page (which I wanted) but it does and WITHOUT appending ReturnUrl.我不确定为什么如果我只有 [allow users=" "/> (并且没有拒绝标签)它甚至仍然强制登录页面(我想要的)但它确实并且没有附加 ReturnUrl。 Hence my issue.因此我的问题。 But after removing any [allow> tags (I tried with individual users, groups, *, etc) the miracle happened and I got a ReturnUrl.但是在删除任何 [allow> 标记(我尝试使用单个用户、组、* 等)之后,奇迹发生了,我得到了一个 ReturnUrl。 It may also have something to do with not supplying a defaultUrl attribute in the [forms> tag.它也可能与未在 [forms> 标记中提供 defaultUrl 属性有关。 I thought I had tried every combo but apparently not.我以为我已经尝试了所有组合,但显然没有。

Anyways, I'm going to do a little more research as to WHY it works this way and I'll post any info I can garner for posterity but right now I'm just giddy that I'm getting a ReturnUrl appended in the query string.无论如何,我将做更多的研究,以了解为什么它会以这种方式工作,并且我会发布我可以获得的任何信息以供后代使用,但现在我只是头晕目眩,因为我在查询中附加了 ReturnUrl细绳。 Thanks again all.再次感谢大家。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM