直接输入网址时,无法从其他浏览器下载页面 [英] Could not downloading a page from another browser when directly enter the URL

查看:67
本文介绍了直接输入网址时,无法从其他浏览器下载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一组页面.第一页是登录",另一页是我的帐户"页面.
用户将首先登录,然后允许进入我的帐户"页面.但是,用户直接从浏览器复制URL并将其粘贴到另一个浏览器.它已下载我的帐户"页面.但是,当用户直接输入URL时,我想重定向到LOGIN页面.请给我一个想法?

Hi,

I have a group of pages . First page is LOGIN ,another one is MY ACCOUNT page.
The user will LOGIN first and then they allow to MY ACCOUNT page.But the user directly copy the URL from the browser and paste it another browser . It is download the MY ACCOUNT page . But i want to redirected to LOGIN page when the user enter directly URL .Please give me idea on that ?

推荐答案

如果登录成功,则需要设置一个会话. br/>
If login success u need to set one session.
Session["login"] = "Success";


在所有屏幕页面加载中,您需要检查会话值.在您的页面加载开始时编写以下代码.


In all screen page load u need to check session value. Write the below code in beginning of ur page load.

if(Session["login"] == null)
{
      Response.Redirect("login page");
}
else if(Session["login"] != "Success")
{
      Response.Redirect("login page");
}


因此,现在只有当您来自登录页面时,它才允许.
然后,在注销集上,


So now it will allow only if u r coming from login page.
Then, on logout set,

Session["login"] = null;


您需要关闭页面会话.
You need to close the Session of the Page.
Response.ExpiresAbsolute = DateTime.Now.Subtract(new TimeSpan(0,1,0));
Response.Expires = 0;
Response.CacheControl = "no-cache";
Response.Cache.SetNoStore();







<pre lang="cs">public static void DisablePageCaching()<br />
{<br />
//Used for disabling page caching<br />
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));<br />
HttpContext.Current.Response.Cache.SetValidUntilExpires(false);<br />
HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);<br />
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);<br />
HttpContext.Current.Response.Cache.SetNoStore();<br />
<br />
}</pre><br />


这篇关于直接输入网址时,无法从其他浏览器下载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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