如何从我的网站删除Cookie

时间:2018-07-30 07:41:39

标签: asp.net cookies web-config

我用Asp.net网站项目开发了一个网站,最近我在上面添加了一些https协议。我的问题是该网站显示它正在保存cookie,而我真的不喜欢保存用户的任何cookie。 我对Cookie不太熟悉,但是我确定没有保存用户Cookie的代码,如何确定用户是否没有Cookie并删除任何设置,为什么会自动发生?

我的项目是一个非常简单的单页网站,没有表单和身份验证

enter image description here

enter image description here

如果需要,这是我的web.config。

 <?xml version="1.0"?>


 <configuration>



  <system.web>

  <httpRuntime enableVersionHeader="false" targetFramework="4.5" />
   <compilation debug="true" targetFramework="4.5"/>


  <customErrors mode="On" />
  <sessionState mode="Off" /> 
  </system.web>
  <system.webServer>



  <httpProtocol>
    <customHeaders>
    <clear />
     <remove name="X-Powered-By" />
    </customHeaders>
  </httpProtocol>

    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files\(compressionType)\(AppPool)\(WebSite)\compressed files">
  <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" />
   <dynamicTypes>
    <add mimeType="text/*" enabled="true" />
    <add mimeType="message/*" enabled="true" />
    <add mimeType="application/x-javascript" enabled="true" />
    <add mimeType="application/json" enabled="true" />
    <add mimeType="*/*" enabled="false" />
  </dynamicTypes>
  <staticTypes>
    <add mimeType="text/*" enabled="true" />
    <add mimeType="message/*" enabled="true" />
    <add mimeType="application/x-javascript" enabled="true" />
    <add mimeType="application/atom+xml" enabled="true" />
    <add mimeType="application/xaml+xml" enabled="true" />
    <add mimeType="*/*" enabled="false" />
    </staticTypes>
  </httpCompression>



  <urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true"/>




  </system.webServer>

</configuration>

非常感谢

1 个答案:

答案 0 :(得分:1)

ASP.Net默认情况下已打开会话状态(https://msdn.microsoft.com/en-us/library/ms178581.aspx),而会话状态默认情况下依赖于cookie。如果不需要会话状态(因为用户未登录等),则可以在web.config文件中将其关闭。只需添加

<sessionState mode="Off"> 

<system.web>

元素。

相关问题