使用POST MVC2 Cookie会话问题 [英] MVC2 Cookieless Session Issue using POST

查看:168
本文介绍了使用POST MVC2 Cookie会话问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,在MVC2启用Cookie会话,在查询字符串中的会话ID是这种情况发生各种形式的岗位重置。有没有需要设置这个工作?一种特殊的路由

For some reason with cookieless session enabled in MVC2, the session id in the query string is reset with every form post that happens. Is there a special route that needs to be setup for this to work?

是否还有其他疑难杂症的,我需要知道的?

Are there any other gotcha's I need to be aware of?

感谢。

推荐答案

Cookie会话做工作MVC2,但是,你不能使用POST作为表单提交的方式。它仅支持使用GET的。此外,所有的形式的动作路径的需要更新到以下模式:

Cookieless sessions do work in MVC2, however, you cannot use POST as the method for the form submit. It only supports the use of GET. Also, all of the action paths on the forms need to be updated to the following pattern:

<form action="<%= Response.ApplyAppPathModifier("/SomeController/SomeAction") %>" method="get">

这将确保会话ID自动传承下去。这是在web.config文件中所需的行来启用Cookie会话:

That will ensure that the session id is automatically passed along. This is the line needed in the web.config file to enable cookieless sessions:

<system.web>
    <sessionState cookieless="true" regenerateExpiredSessionId="true"></sessionState>
</system.web>

有了这两个以上的变化,一切正常!

With those two above changes, everything worked!

如果你有兴趣在获取了POST,Cookie会话和MCV2工作的一种解决方法,我发现下面的页面。 <一href=\"http://www.developer.com/net/asp/article.php/2216431/Enabling-POST-in-Cookieless-ASPNET-Applications.htm\"相对=nofollow>在无Cookie ASP.NET启用POST 这是不适合我的项目,因为我不能够使用JavaScript。

If you are interested in a workaround for getting POST to work with Cookieless session and MCV2, I found the following page. Enabling POST in Cookieless ASP.NET This wasn't well suited for my project because I am not able to use JavaScript.

这篇关于使用POST MVC2 Cookie会话问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆