当用户首次打开网站时,如何打开页面而不是default.aspx [英] How to Open a page instead of default.aspx, when user firstly opens a website

查看:77
本文介绍了当用户首次打开网站时,如何打开页面而不是default.aspx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在asp.net创建一个网站..我希望当用户第一次打开网站时,应该打开一个ajax / jquery类型的窗口,他/她必须输入姓名和电话号码。然后可以进入网站...

i尝试了一个弹出窗口,但这不是我想要的,因为我需要一个冰沙页面应首先打开



好​​像你打开这个网站的事情发生了我需要相同类型的窗口



[垃圾链接删除]



请帮助我..提前谢谢

I am creating a website in asp.net..i want as user first time opens the website a ajax/jquery type window should open where he/she has to enter name and phone no. and then can proceed to the website...
i tried a pop up window but that was not i wanted as i need a smoothie page should be opened first

as if you open this site the thing happens i need the same one the same type of window

[spam link removed]

please help me..thanks in advance

推荐答案

由于您不需要任何JavaScript驱动的警报框,剩下的概念是将用户重定向到表单等待他输入其详细信息的页面。



在ASP.NET中你可以使用会话 [ ^ ]变量与用户的Session一起使用。会话是在他第一次访问您的网站时创建的,并在他离开您的网站后立即被删除;关闭浏览器等。在ASP.NET中,您可以创建一个Session变量,因为



Since you don't want any JavaScript powered alert box, then the remaining concept is to just redirect the user to a page where a form is waiting for him to enter his details.

In ASP.NET you can use the Session[^] variables to work with the Session of the user. Session is created when he first visits your website and are removed as soon as he leaves your website; closes the browser etc. In ASP.NET you can create a Session variable as

Session["variable_name"] = "value";





现在这个变量对于每个用户和每个会话都是不同的。您可以使用它们来保存与Session相关的值。关于会话变量的好处是,如果要在用户关闭会话之前删除它们,可以将其删除。



你想检查用户是否第一次访问并为他设置了名称,你可以为名称创建一个变量(你可以创建变量来存储phone_number;但我只会提供名称的答案),因为这个





Now this variable will be different for every user and for every session. You can use them to save Session related values. Good thing about session variables is that you can remove them if you want to remove them before the user closes the session too.

You wanted to check if the user is visiting for the very first time and has set the name for him or not, you could create a variable for the name (you can create the variable to store the phone_number too; but I am going to provide the answer for the name only), as this

Session["name"] = null;





..现在当他访问你的网站时,在你的主页面(布局页面,如果你正在使用ASP的Web页面框架) .NET;其他人有一个母版页)写这段代码





.. now when he visits your website, in your master page (layout page if you're using Web Pages framework of ASP.NET; others would have a master page) write this code

if(Session["name"] == null) {
   // Redirect him to the page
} else {
   // it contains the value for his name
}





记住:这些变量在所有页面上都相同,因此请确保您只在重定向时用户不在表单所在的网页上。因为如果你也从表单页面重定向他,浏览器将终止请求说请求导致无限重定向。 https://en.wikipedia.org/wiki/URL_redirection [ ^ ]



Remember: These variables are same on all of the pages, so make sure that you only redirect when the user is not on the web page where the form is. Because if you redirect him from the form page too, the Browser would terminate the request saying, "Request resulted in an infinite redirect". https://en.wikipedia.org/wiki/URL_redirection[^]


在页面加载的default.aspx.cs编码页面上使用Response.Redirect(yourpagename.aspx)



on default.aspx.cs coding page in a page load use the Response.Redirect("yourpagename.aspx")

protected void Page_Load(object sender, EventArgs e)
    {
        Response.Redirect("~/login.aspx");
    }


这篇关于当用户首次打开网站时,如何打开页面而不是default.aspx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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