简体   繁体   English

查询字符串参数在请求时丢失

[英]Query String Parameter Being Lost on Request

i'm developing an MVC 4 web application. 我正在开发MVC 4 Web应用程序。

I'm trying to make an url that changes in an authorized/unauthorized context. 我正在尝试制作在授权/未经授权的上下文中更改的网址。

I'm generating the following url for unauthorized user: 我为未经授权的用户生成以下网址:

http://localhost/vendas-web/Login?ReturnUrl=%2Fvendas-web%2FClienteNovo%2FIndex%299999 http:// localhost / vendas-web / Login?ReturnUrl =%2Fvendas-web%2FClienteNovo%2FIndex%299999

The first time I've tested, it worked just fine. 第一次测试,效果很好。

But.. the second time I've tried, the query string got lost.. and the url turned into: 但是..我第二次尝试,查询字符串丢失了..并且URL变成了:

http://localhost/vendas-web/Login http:// localhost / vendas-web / Login

When i test it against chrome on anonymous tab, it works FINE. 当我针对匿名选项卡上的chrome测试它时,它的效果很好。 When i change the value of the last parameter, it works FINE. 当我更改最后一个参数的值时,它的效果很好。

There's some sort of cache related to this ? 有某种与此相关的缓存吗?

What i'm doing wrong ? 我做错了什么?

Soo, my question is: 如此,我的问题是:

How do i keep my full url in any scenario ?? 在任何情况下,我如何保留我的完整网址?

Ty

There's really not enough information here, but what you're likely talking about is that the first time a user needs to be authorized, they are automatically redirected to the first URL, which includes the ReturnUrl bit. 此处确实没有足够的信息,但是您可能ReturnUrl是,第一次需要授权用户时,他们会自动重定向到第一个URL,其中包括ReturnUrl位。 That's built into the framework to allow the user to be redirected back to that URL after logging in. However, if you need to persist this past that initial first redirect to the login page, that's on you. 该框架内置在框架中,以允许用户在登录后重定向回该URL。但是,如果您需要保留最初的首次重定向到登录页面的内容,那就在您身上。 Any links must manually add the query string param: 任何链接都必须手动添加查询字符串参数:

@Url.Action("SomeAction", new { ReturnUrl = Request["ReturnUrl"] })

And any forms must include it as a hidden input: 并且任何形式都必须将其作为隐藏输入包括在内:

@Html.Hidden("ReturnUrl", Request["ReturnUrl"])

Otherwise, yes, it will be lost, because the literal URL you're now requesting doesn't include it. 否则,是的,它将丢失,因为您现在请求的文字URL不包含它。 It's not just magically appended. 它不只是神奇地附加了。

My problem was cache... 我的问题是快取...

I've used this annotation to avoid using cache by application. 我已使用此注释来避免按应用程序使用缓存。

[OutputCache(NoStore = true, Duration = 0)]

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

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