Porting Web.Config to ASPNET5

I am upgrading my project to ASPNET5. I am hitting an error regarding updating my web.config file.

I tried using a package Microsoft.Framework.ConfigurationModel.Xml

to read the URL rewriting configuration. The configuration looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="MainRule" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_URI}" matchType="Pattern" pattern="api/(.*)" negate="true" />
            <add input="{REQUEST_URI}" matchType="Pattern" pattern="signalr/(.*)" negate="true" />
          </conditions>
          <action type="Rewrite" url="default.html" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

      

but of course I am having recurring key issues when it tries to convert it to an object that uses aspnet5.

enter image description here

What's the best way to migrate an existing web.config to the new aspnet model? This is a small case that I understand, but in the real world these configs are very intense.

I've created a project that I hope to share with others when I get a few of these cases.

+3


source to share


1 answer


The web.config file you posted only has URL rewriting rules for iis. Do you really need to access themes from your application? IIS will read them directly from the web.config, but you don't need that in your application, so you don't need to try to parse this file with new classes in Microsoft.Framework.Configuration at all.

if your application needs different settings, you can also use the json.config file as shown in many examples for your own application settings.

you can still delete this web.config file to the root of the application and, assuming your application is hosted in IIS, it should still do its job and tell IIS to rewrite the urls. you shouldn't rename it to config.xml file as it seems you did, since IIS won't notice the file unless named web.config



Why would you need to refer to these URL rewriting rules from application code at all, since it's IIS and not application code that does the URL rewriting?

I think the new paradigm is using json.config and / or environment variables in azure to configure the application

The only thing you can use the web.config file is the IIS setting, but that is independent of the application configuration and that is the only thing you would use the web.config files to move forward and you will not need to access the website. config file from application code.

0


source







All Articles