简体   繁体   English

Web.config更改文件的默认位置

[英]Web.config changing file default location

I've have a tricky question for you: 我有一个棘手的问题要问你:

In Visual C# IDE , how do you change the location of a file within a seperate folder? Visual C# IDE ,如何更改文件在单独文件夹中的位置?

So for example 所以举个例子

The inital path of this folder was Webproject/folder1/Default.aspx in VS 2008, I converted this to 2010 and needed to rename the Default.aspx to folder1Default.aspx to make it work in 2010, because I couldnt have more than one Default.aspx. 此文件夹的初始路径是VS 2008中的Webproject / folder1 / Default.aspx,我将其转换为2010,并且需要将Default.aspx重命名为folder1Default.aspx才能在2010年正常工作,因为我无法使用多个Default .aspx。 Now when I attempt to navigate to this folder, it can't open this as the default page. 现在,当我尝试导航到该文件夹​​时,它无法将其作为默认页面打开。 How can I set this page to be the default location for this specific folder? 如何将该页面设置为该特定文件夹的默认位置?
If the path were Webproject/folder1/folder1Default.aspx, how could I change this location using the web.config file? 如果路径为Webproject / folder1 / folder1Default.aspx,如何使用web.config文件更改此位置?

Thanks. 谢谢。

You did this, but there should be only 1 default or index file which are defined in IIS or config file. 您这样做了,但是在IIS或配置文件中应该只定义了1个默认文件或索引文件。

<location path="folder1">
     <system.webServer> 
       <defaultDocument enabled="true">
         <files> 
          <add value="folder1Default.aspx"/> 
         </files> 
       </defaultDocument> 
     </system.webServer> 
    </location>

I have done it like this in config file 我已经在配置文件中这样做了

<system.webServer>
    <defaultDocument>
      <files>
        <remove value="default.aspx" />
        <remove value="iisstart.htm" />
        <remove value="index.html" />
        <remove value="index.htm" />
        <remove value="Default.asp" />
        <remove value="Default.htm" />
        <add value="folder1Default.aspx" />
      </files>
    </defaultDocument>
  </system.webServer>

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

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