开发者

Changing startup page at run time

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜