如果我们直接输入“URL”,如何设置它将显示错误消息 [英] How to set that if we enter directly "URL" it will show the error message
本文介绍了如果我们直接输入“URL”,如何设置它将显示错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hai,
我有一个#net网络应用程序。它有三种类型的用户。如果用户直接输入URL,则假设地址栏会显示错误信息。怎么办呢。
提前致谢
Hai,
I have a c# .net web application.It is having 3 type of users.Suppose if the user enters the "URL" directly in the address bar it will show the error message.How it can be done.
Thanks in advance
推荐答案
请按照以下步骤操作:
将您的主页视为Home.aspx
在home.aspxpage_load
事件中你必须将会话设置为
Follow these steps:
Consider your home page asHome.aspx
in the home.aspxpage_load
event you have to Set the session as
Session["IsValidEntry"] ="Yes";
然后在page_load事件的每一页中,您都可以检查的会话值IsValidEntry
如果是是
那么它是该网站的有效条目。
否则你可以显示一条消息说
then In each and every page of page_load event, you can check the session value of IsValidEntry
if it is "Yes
" then it is a valid entry to the site.
else you can show a message saying
Response.Write("<script>alert('Not a valid Entry , Pls use the valid URL');</script>");
之后你可以重定向到你的主页或默认页面..
希望你明白:)
after that you can redirect to your home page or default page..
Hope you understood :)
这篇关于如果我们直接输入“URL”,如何设置它将显示错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文