开发者

Changing startup page at run time

开发者 https://www.devze.com 2023-02-26 04:49 出处:网络
In a VS2010 ASP.Net website is it possible to alter the \'Specific Page\' at project start up? Basically our startup page requires todays date to be passed in as a query string to prevent people from

In a VS2010 ASP.Net website is it possible to alter the 'Specific Page' at project start up? Basically our startup page requires todays date to be passed in as a query string to prevent people from permanently bookmarking the page.

Obviously this causes headaches for developers as they have to manually change the date on their startup page every day. Is there any way of automatically changing the query string either by using an environment variable of some kind or a build event? Currenty our Start Action is set to: Specific Page: Example.aspx?date=18/04/2011 it is the part in bold I would like to change when starting the pro开发者_如何学Pythonject.

Many thanks.


Pseudocode:

void OnBeginRequest()
{
#if DEBUG
    if(Request.Url.Host == "localhost" && Request["date"] == null)
        Redirect(Request.Url + "?date" + DateTime.Today);
#endif
}


The easiest way to do so is to create a page (temp.aspx), set the page as the startup page, and in the page_load event redirect the user to the new page. like this

response.redirect("Example.aspx?date=" + system.datetime.now.toshortdatestring());
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号