如何在我的网站上设置默认页面 [英] How to set the default page in my website

查看:96
本文介绍了如何在我的网站上设置默认页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,我已经在iis(5.1)Local System中发布了我的网站,并且运行成功.但是这里的问题是使用默认URL来使用该网站,如果我运行同一网站的另一个URL,我需要使用没有发生的默认URL来运行我的网站.我的网站正在运行无论给出什么页面URL都不会发生的情况.
解决方案是什么.


我们将不胜感激.

Hi Friends , i have published my website in iis(5.1) Local System and it is running success full. But the problem here is am using the Default URL to use the website, if i run another url of the same website i need to run my website with the default URL which is not happening. My website is running what ever the page url is given which should not happen.
What is the solution.


Any help will be appreciated.

推荐答案

在您网站的默认页面或登录页面中,将会话变量创建为Session ["UserId"].

In the default page or the login page of your website create a session variable as Session["UserId"].

Session["UserId"]=username;



然后在网站上每隔一页的Page_Load或母版页的Page_Load中,检查此变量是否具有该值,否则将用户重定向到默认"页面



Then on the Page_Load of every other page in the website or in the Page_Load of master page check if this variable has the value, else redirect the user to the Default page

if(Session["UserId"]==null)
{
Response.Redirect("Default.aspx");
}




在会话开始事件中添加以下代码..


add the below code in session start event..
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
      Response.Redirect("Default.aspx");
      'put here your default page
End Sub


并设置表单身份验证并提供登录URL,如果您使用母版页,则最好在global.asax会话开始事件中声明会话变量,并在母版页中使用类似上面的内容页面加载事件.可以....
and set forms authentication and provide login url, if u use master pages, better declare session variable in global.asax session start event and use something like above in the master page page load event. it works....


这篇关于如何在我的网站上设置默认页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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