<configuration>
<system.webServer>
<staticContent>
<remove fileExtension =".wav"/>
<mimeMap fileExtension=".wav" mimeType="audio/wav" />
</staticContent>
</system.webServer>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
i try this code but not worked. Help me to solve it.
thanks
Related
Here is my web.config file,
<system.web>
<compilation debug="true" targetFramework="4.7.1" />
<httpRuntime targetFramework="4.7.1" maxRequestLength="2147483" executionTimeout="3600" requestValidationMode="2.0" requestPathInvalidCharacters=""/>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>
Any help would be appreciated.
I am having trouble doing config transform, adding app settings on nuget package install where element appSetting may or may not exist.
What I want to happen:
appSetting element does not exist
Insert appSetting element and its children
appSetting element exist
Insert children if missing
I only get one or the other to work, but not both occasions.
web.config.install.xdt
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings xdt:Transform="InsertIfMissing" >
<add key="Swagger.Contact.Name" value="Some Name" xdt:Transform="InsertIfMissing" />
<add key="Swagger.Contact.Email" value="some#email.address" xdt:Transform="InsertIfMissing" />
</appSettings>
</configuration>
Example 1
web.config BEFORE
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" maxRequestLength="51200" />
<customErrors mode="Off" />
</system.web>
</configuration>
appSettings element not present before transformation.
web.config AFTER
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" maxRequestLength="51200" />
<customErrors mode="Off" />
</system.web>
<appSettings>
<add key="Swagger.Contact.Name" value="Some Name" />
<add key="Swagger.Contact.Email" value="some#email.address" />
</appSettings>
</configuration>
Example 2
web.config BEFORE
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" maxRequestLength="51200" />
<customErrors mode="Off" />
</system.web>
<appSettings>
<add key="Other.Key" value="With Some Value" />
</appSettings>
</configuration>
appSettings element present before transformation.
web.config AFTER
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" maxRequestLength="51200" />
<customErrors mode="Off" />
</system.web>
<appSettings>
<add key="Other.Key" value="With Some Value" />
</appSettings>
</configuration>
Nothing happens in example 2 as the appSettings element already exist, I would like it to still evaluate its child elements and insert those if they do not exist, but it seems they are just ignored. Is there any other value for the attribute xdt:Transform I can use, or any other hacks to work around this issue?
I had a similar problem quite a while back. The workaround I applied was to have two entries with <appSettings> in the XDT file, one to check if its absent and if yes, then go ahead and insert it. The other was for the scenario when the <appSettings> element was already present. Here is short snippet to help you with your problem:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings xdt:Transform="InsertIfMissing">
</appSettings>
<appSettings>
<add key="Swagger.Contact.Name" value="Some Name" xdt:Transform="InsertIfMissing" />
<add key="Swagger.Contact.Email" value="some#email.address" xdt:Transform="InsertIfMissing" />
</appSettings>
</configuration>
Let me know if this works for you.
I have an error while using ap sprites.Am not able to do it.
i have added the following code in web.config
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add type="Microsoft.Samples.Web.ImageOptimizationModule"
name ="Microsoft.Samples.Web.ImageOptimizationModule"/>
</modules>
</system.webServer>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="Microsoft.Web.Samples" assembly="Microsoft.Web.Samples.ImageSprite" />
</controls>
</pages>
<httpModules>
<add type="Microsoft.Samples.Web.ImageOptimizationModule"
name="Microsoft.Samples.Web.ImageOptimizationModule" />
</httpModules>
<compilation debug="true" targetFramework="4.0" />
</system.web>
and i have also created a folder App_Sprites.And added reference of ImageSprite and ImageOptimizationFramework
This is mostly a guess, but you might have to qualify the type name in your declarations with the assembly name.
I don't know what the assembly name for Microsoft.Samples.Web.ImageOptimizationModule is, but let's say it's Microsoft.Web.Samples.ImageSprite:
<add type="Microsoft.Web.Samples.ImageOptimizationModule, Microsoft.Web.Samples.ImageSprite"
name ="Microsoft.Web.Samples.ImageOptimizationModule"/>
I made the following changes in my web.config file and its works fine and also added WebForms.dll reference.
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<pages>
<controls>
<add tagPrefix="asp" namespace="Microsoft.Web.Samples" assembly="Microsoft.Web.Samples.ImageSprite" />
</controls>
</pages>
<httpModules>
<add type="Microsoft.Web.Samples.ImageOptimizationModule"
name="Microsoft.Web.Samples.ImageOptimizationModule"/>
</httpModules>
</system.web>
<system.webServer>
<modules>
<add type="Microsoft.Web.Samples.ImageOptimizationModule"
name="Microsoft.Web.Samples.ImageOptimizationModule"/>
</modules>
</system.webServer>
</configuration>
For Detail Explanation of Sprite along with the demo and Sample Download see following link
https://web.archive.org/web/20211020150102/https://www.4guysfromrolla.com/articles/101310-1.aspx
My page is written in ASP.Net, and our site runs IIS 7.5.
I'm trying to receive an Xml document from an outside source posting to a page in our website. I can send a test document from a web page and receive it, using Content-Type “application/x-www-form-urlencoded”. The sender's documents are Content-Type "text/xml." I have modified the web.config to try various things, all of which still give us a "blank" document from the sender. Is there some setting that I"m still missing that would cause this?
My web.config settings are:
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
<sessionState mode="Off" cookieless="true" />
<httpRuntime requestValidationMode="2.0" enableVersionHeader="false" />
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
</webServices>
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="P3P" value="policyref='https://oursite/w3c/p3p.xml',CP='NON DSP COR CUR OUR IND PUR ONL PHY'" />
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="POST,GET" />
<add name="Access-Control-Allow-Headers" value="content-type:text/xml;charset=utf-8"/>
</customHeaders>
</httpProtocol>
<staticContent>
<mimeMap fileExtension=".aspx" mimeType="text/xml" />
<mimeMap fileExtension=".aspx" mimeType="application/x-www-form-urlencoded"/>
</staticContent>
<httpErrors errorMode="Detailed" />
<httpCompression>
<staticTypes>
<add mimeType="text/xml" enabled="true"/>
</staticTypes>
<dynamicTypes>
<add mimeType="text/xml" enabled="true"/>
</dynamicTypes>
</httpCompression>
<security>
<requestFiltering>
<fileExtensions allowUnlisted="true" />
</requestFiltering>
</security>
</system.webServer>
i'm getting this "Unrecognized configuration section system.web/configuration when i set my admin,staff and user authentication .please help me with this.by here i provide the web.config code
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings/>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
<add name="ASPNETDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Se7en\Desktop\Personal\VIVA\1\App_Data\ASPNETDB.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
-->
<configuration>
<system.web>
<authentication mode="Forms">
<forms loginUrl="Login.aspx">
<credentials passwordFormat="Clear">
<user name="admin" password="password"/>
</credentials>
</forms>
</authentication>
<authorization>
<allow users="*"/>
</authorization>
<compilation debug="true"/>
</system.web>
<location path="adminstrator">
<system.web>
<authorization>
<allow users="adminstrator"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<location path="staff">
<system.web>
<authorization>
<allow users="staff"/>
<deny users="*"/>
<allow roles="adminstrator" />
</authorization>
</system.web>
</location>
<location path="user">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
<!--
<authentication mode="Forms"/>
-->
<roleManager enabled="true"/>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Generic"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Linq"/>
<add namespace="System.Xml.Linq"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
</configuration>
Try this:
<configuration>
<appSettings/>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
<add name="ASPNETDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Se7en\Desktop\Personal\VIVA\1\App_Data\ASPNETDB.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<location path="adminstrator">
<system.web>
<authorization>
<allow users="adminstrator"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<location path="staff">
<system.web>
<authorization>
<allow users="staff"/>
<deny users="*"/>
<allow roles="adminstrator" />
</authorization>
</system.web>
</location>
<location path="user">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
<system.web>
<roleManager enabled="true"/>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Generic"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Linq"/>
<add namespace="System.Xml.Linq"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms loginUrl="Login.aspx">
<credentials passwordFormat="Clear">
<user name="admin" password="password"/>
</credentials>
</forms>
</authentication>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>