ASP.NET 3.5中的URL问题 [英] URL issue in ASP.NET 3.5

查看:65
本文介绍了ASP.NET 3.5中的URL问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在ASP.NET 3.5中有一个Web应用程序.
我的问题是,当直接在浏览器中输入网址时,如何阻止打开网页.我希望用户仅通过应用程序访问网页,而不是直接在浏览器中输入网址.

非常感谢您的帮助.

谢谢.

Hi,
I have a web application IN ASP.NET 3.5.
My question is how can I prevent the web page to open when the url is directly entered in the browser. I want the user to access the web page only through the application and not directly entering the Url in a browser.

Your help will be highly appreciated.

Thanks.

推荐答案

从应用程序打开页面时,您可以传递令牌,以便页面知道它已从应用程序打开.如果令牌不存在,则显示错误页面.
When the page opens from your app you can pass a token so that the page knows it''s been opened from the app. If the token is not present then display an error page.


您无权阻止用户键入URL并加载页面,也没有任何控制权.这很好.如果您分析了Web的工作原理,便可以理解.

如果您解释问题的目的,则可能会得到有用的建议,具体取决于目标是什么.



除了完成这个毫无意义的任务,您还可以做一些更合理的事情.确切地说,在服务器端,如果您发现引用是合法的,则可以检查引用并生成一些必要的上下文,如果引用不合法,则可以执行其他操作,例如,重定向到错误页面.请参阅:
http://msdn.microsoft.com/en-us/library/system. web.httprequest.urlreferrer.aspx [ ^ ].

—SA
You have no right to prevent the user from typing the URL and loading a page, nor you have any control over it. And this is good. You could understand it if you analyzed how Web works.

If you explain the purpose of your question, you might get a useful advice, depending on what is that purpose.



Instead of having this pointless task, you can do something more reasonable. For exactly, one the server side you can check up the referral and generate some essential context if you find the referral is legitimate and do something else if it is not, for example, redirect to error page. Please see:
http://msdn.microsoft.com/en-us/library/system.web.httprequest.urlreferrer.aspx[^].

—SA



您应该使用表单身份验证来防止用户直接输入URL并访问页面.他们将必须通过Root目录,即您的主页.

在您的web.config
中使用它
Hi,
You should use forms authentication to prevent the user to directly enter the url and accessing the page. They will have to go through the Root directory, that is your home page first.

Use this in your web.config

<allow users="*"/>
<deny users="?"/>



-AK



-AK


这篇关于ASP.NET 3.5中的URL问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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