如果用户从浏览器访问URL,则重定向到登录页面 [英] redirect to login page, if user acces the url from browser

查看:310
本文介绍了如果用户从浏览器访问URL,则重定向到登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

helloo everyone,



i使用asp.net c#,sqlserver 2005创建了一个Web应用程序。



在这里第一页是登录页面..如果用户有他可以登录的用户名和密码。



我有很多内页。



他可以打开应用程序,,,复制并粘贴内页链接。



如果他粘贴内页链接....它应该重定向到登录页面。



不要在没有登录的情况下打开申请。



但是在这里,我可以在粘贴内页链接后访问该应用程序。



但我不需要这个,如果他在浏览器中粘贴内页链接,它应该重定向到登录页面。



请帮助..谢谢

helloo everyone,

i have created a web application using asp.net c#, sqlserver 2005.

In this the first page is login page..if user has the username and password he can login.

I have many Inner pages.

he can open the application,,, copy and paste the Inner pages link.

if he paste the inner pages link....it should redirect to login page.

donot open the application without login.

But here, i can access the application, after pasting the inner pages link.

But i don''t need this, if he paste the inner page link in browser, it should redirect to login page.

Please help..thank you

推荐答案

你可以使用这个会议。当您注销时,您需要清除所有会话值。

如果您使用母版页,那么您可以将此代码写入母版加载事件。



you can use session for this. When your logged out you need to clear all session values.
if you using master page then you can write this code to master page load event.

if (Convert.ToString(Session["UserName"]).Length <= 0)
       {
           Response.Redirect(Page.ResolveUrl("~/default.aspx"));
       }       





这里的默认页面是你的登录页面。





并在注销时你需要写。







here default page is yours login page.


and on logout you should need to write.


Session.Abandon();
Response.Redirect("../Default.aspx");


您可能想要搜索ASP.Net 授权 [ ^ ]& 身份验证 [ ^ ]。这将是一个更加坚实的解决方案。



CP中还有一篇文章: ASP.NET身份验证和授权 [ ^ ]



祝你好运,

OI
You might want to search ASP.Net Authorization[^] & Authentication[^]. That will be a more solid solution.

There is also an article in CP: ASP.NET authentication and authorization[^]

Good luck,
OI


这篇关于如果用户从浏览器访问URL,则重定向到登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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