Using VS2010 to develop a jump page aspx

Source: Internet
Author: User

In the development project process, because to integrate Cognos report through the URL, but the Cognos report itself URL length process, then need to develop a jump page, below we use VS2010 to develop a jump page default.aspx

1: Open VS2010 new Web site

2: Select C # language, ASP. NET Empty Web site

3: Project Jumppage has been created, there is a Web. config profile by default

4: In this example, the Web. config content is, add the appsettings node, for the following operations to use

<?xml version="1.0"?><!--For more information about how to configure an ASP. NET application, go to http://go.microsoft.com/fwlink/?linkid=169433--><configuration> <system.web> <compilation debug="true"targetframework="4.0"/> </system.web> <appSettings> <add key="1"Value="http://www.baidu.com/"/> <add key="2"Value="http://www.cnblogs.com/"/> </appSettings></configuration>

4: Create a new file, select Web Form, the system is named Default.aspx by default

5: As shown, each ASPX page corresponds to a aspx.cs page, the former is a display, the latter is a design event and code

6: An Page_Load method is automatically generated in the aspx.cs of ASPX corresponding to this example Default.aspx.cs encoded as follows

 protected voidPage_Load (Objectsender, EventArgs e) {        //get a pass-through Reportkey, if the user is prompted to select a report        if(request.querystring["Reportkey"] ==NULL) {Clientscript.registerstartupscript ( This. GetType (),"message","<script language= ' javascript ' >alert (' Please select a report! ');</script>"); return; }        //if not empty, use response to redirect to report URL        Else        {            stringReportkey = request.querystring["Reportkey"]; stringReportpath =System.configuration.configurationmanager.appsettings[reportkey].            ToString ();        Response.Redirect (Reportpath); }    }

Code parsing: System.configuration.configurationmanager.appsettings[reportkey]. ToString (); The function is to take out the value of key reportkey in the <appSettings> node in the Web. config configuration file

7: Publish Web site in Browser view effect

Access Web site without parameters

Access Web site with parameter key

Effect, successfully jump to Key=1 specified address <add key= "1" value= "http://www.baidu.com/"/>

8: Logical Interpretation

Access the ASPX page to specify the path of the jump to the parameter, the path of the jump in the Web. config configuration

Using VS2010 to develop a jump page aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.