简体   繁体   English

运行.aspx页面,该页面已“添加为链接”

[英]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 '. 我在Visual Studio中创建了一个名为“ MyProject ”的项目,并向其中添加了一个名为“ MyPage.aspx ”的.aspx文件。

Now, I created another project in that same solution named ' NewProject '. 现在,我在相同的解决方案中创建了另一个名为“ NewProject ”的项目。 I added ' MyPage.aspx ' from ' MyProject ', to new Project, using Add as link option. 我使用“添加为链接”选项将“ MyProject ”中的“ MyPage.aspx ”添加到了新项目中。

在此处输入图片说明

在此处输入图片说明

Now if I make ' NewProject ' as startup project, and ' MyPage ' from ' NewProject ' as Startpage, then it says The resource cannot be found . 现在,如果我将' NewProject '作为启动项目,并将' NewProject '的' MyPage '作为Startpage,则说找不到资源

How to achieve this? 如何实现呢?

EDIT : Consider that MyPage from MyProject is fetching displaying a Value from Database 'abc'. 编辑 :考虑到MyProject的MyPage正在从数据库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'. 数据库'abc'的连接字符串在Myproject的Web.config中定义。现在,我想创建另一个项目,仅在我想从数据库'xyz'而不是从数据库'获取数据的情况下,我想要与MyPage相同的功能。 abc”。 I shall do that by adding my connection String for 'xyz' in NewProject 我将通过在NewProject中为“ xyz”添加连接字符串来做到这一点

You need to add project reference from 'MyProject' to NewProject through add reference. 您需要通过添加引用将项目引用从“ MyProject”添加到NewProject。

If using IIS 7 or IIS 7.5 you can use 如果使用IIS 7或IIS 7.5,则可以使用

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

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

or you can try as in global.ascx 或者您可以像在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");
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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