简体   繁体   中英

Run .aspx page, which is 'Added as Link'

I created a project in Visual Studio named ' MyProject ', and Added .aspx file to it named ' MyPage.aspx '.

Now, I created another project in that same solution named ' NewProject '. I added ' MyPage.aspx ' from ' MyProject ', to new Project, using Add as link option.

在此处输入图片说明

在此处输入图片说明

Now if I make ' NewProject ' as startup project, and ' MyPage ' from ' NewProject ' as Startpage, then it says The resource cannot be found .

How to achieve this?

EDIT : Consider that MyPage from MyProject is fetching displaying a Value from Database 'abc'. The connection string for database 'abc' is defined in Web.config of Myproject Now I want created another project, wherin I want the same functionality as that of MyPage, only if I want to fetch data from database 'xyz' and not database 'abc'. I shall do that by adding my connection String for 'xyz' in NewProject

You need to add project reference from 'MyProject' to NewProject through add reference.

If using IIS 7 or IIS 7.5 you can use

<system.webServer>
  <defaultDocument>
    <files>
      <clear />
      <add value="MyPage.aspx" />
    </files>
  </defaultDocument>
</system.webServer>

http://www.iis.net/ConfigReference/system.webServer/defaultDocument

or you can try as in global.ascx

public class Global : System.Web.HttpApplication
{
    protected void Application_BeginRequest(object sender, EventArgs e)
    {
        if (Request.Url.AbsolutePath.EndsWith("/"))
        {
            Server.Transfer(Request.Url.AbsolutePath + "MyPage.aspx");
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM