3

Cookies in ASP.NET are causing me some problems.

For the most part, I want to use cookieless sessions. This is mainly to get around a problem where safari won't let me set the cookies from an iFrame. So that part all works fine. Cookieless sessions do the job.

However, I have a page which is called from a POST. It uses a post to pass in a hidden field from a form which then does some stuff....you don't really need to know what.

So it turns out that when cookieless sessions are on, the POST is disabled and only GETS can happen in ASP.NET web forms. This is breaking my functionality.

What I want to do is add a web.config to the folder that contains my POSTing pages to go back to normal cookie sessions so I can get my POSTs working again, but this doesn't work.

<?xml version="1.0"?>
 <configuration>
  <system.web>
     <sessionState cookieless="false" />
  </system.web>
 </configuration>

Does anyone know a way of making a folder work with normal cookie sessions while the rest of the site works with cookieless sessions?

4

1 回答 1

1

我找到了解决方案:

我所做的是创建一个 HTTP 处理程序(一个 .ashx 文件)。这从 Request.Form 中获取特定的 post 值,并将它们标记为 Querystring 参数。然后重定向到我的原始页面,该页面现在查找 Querystring 参数而不是 Form 参数。呸!

HTTP 处理程序是我的应用程序现在发布的内容——它是一个 Facebook 签名请求。

所以好消息是,我现在可以使用 HTTP 处理程序了——你每天都会学到一些东西。

于 2012-05-18T10:38:45.227 回答