I have the following section added to my web.config:
<system.webServer>
<caching>
<profiles>
<add extension=".html" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".htm" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".js" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".css" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
</profiles>
</caching>
</system.webServer>
which was taken directly from here
but I am getting an error in my web.config, saying:
Unrecognized configuration section system.web/caching/profiles
also, I see this in visual studio:
The element caching has invalid child element 'profiles', List of possible expected: cache, outputcache, outputcacheSettings, sqlCacheDependency'
did something about this configuration change as I see alot of examples on the web with this exact configuration?
In your screenshot you have the caching under <system.web> and not <system.webServer> and since profiles is not a valid element under <caching> for <system.web> you will get that error.
What you show in code example is under <system.webServer>, what you show in your screenshot is under <system.web>, it needs to be under webServer for it to get the profiles option, under system.web like you had it offers all those options that the error you received was talking about, behaves differently depending on where you call it from
Related
How can i add entities/parameters into my asp.net mvc application. I want to allow cors to send ajax-requests into a database via asp.net webservice. Does anyone have experience fixing this?
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Headers" value="accept, content-type" />
<add name="Access-Control-Allow-Origin" value="http://localhost/QvAJAXZfc/opendoc.htm?document=test.qvw&lang=en-US&host=QVS%40servb"/>
<add name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" />
</customHeaders>
It shows me an error underlining the lang and the host section of the value, where i want to access.
Warm regards
Make sure that you are adding them in correct section. Change the whole url to just localhost and it will work
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Headers" value="accept, content-type" />
<add name="Access-Control-Allow-Origin" value="http://localhost"/>
<add name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
I have images in my ~/Content/Images folder. And these images are used in Layout and other pages. When i request a page "Contact", it loads images referenced on that page and i can see requests in IIS log for each image load. This is ok for the first request. and for 2nd and further requests to contact page, i do not want these images to be requested from server again, want them to be load from cache.
I don’t want to change security settings in my web.config
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="no-cache, no-store" />
<add name="Pragma" value="no-cache" />
<add name="Expires" value="-1" />
</customHeaders>
</httpProtocol>
</system.webServer>
I am trying to add output cache setting for images as
<system.webServer>
<caching>
<profiles>
<add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
<add extension=".png" policy="CacheUntilChange" kernelCachePolicy="DontCache" location="Client" />
</profiles>
</caching>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
</staticContent>
</system.webServer>
But above setting still sending a requests for images each time I am refreshing the page.
do not want session values to be cached so I set cache-control to no-cache.
I want to stop these requests for static images until I change it.
What i am missing here?
I've created an application that I want to get logging to Slack for a particular purpose. I've already confirmed that it is working logging to a RollingFile and to Seq. I've added in serilog.sinks.slackclient and the application runs, and logs, but nothing shows up in my Slack channel.
Can someone verify whether there is an issue with my config?
from app.config (obviously xxx, yyy, zzz are substituded for key values.):
<add key="serilog:minimum-level" value="Debug" />
<!--<add key="serilog:using:RollingFile" value="Serilog.Sinks.RollingFile" />-->
<add key="serilog:using:Slack" value="Serilog.Sinks.Slack" />
<add key="serilog:write-to:Slack" value="https://hooks.slack.com/services/xxx/yyy/zzz" />
<add key="serilog:write-to:Seq.serverUrl" value="http://localhost:5341/" />
<add key="serilog:write-to:RollingFile.pathFormat" value="C:\Logs\Serilog\Test-{Date}.txt" />
<add key="serilog:write-to:RollingFile.retainedFileCountLimit" value="10" />
The parameter name webhookUrl is missing out of the write-to directive:
<add key="serilog:write-to:Slack.webhookUrl"
value="https://hooks.slack.com/services/xxx/yyy/zzz" />
I am struggling in implementing caching in my MVC application.
Below is the code I have added in my root directory web.config file
<system.webServer>
<caching>
<profiles>
<add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:20:00" location="Client" />
<add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:20:00" location="Client" />
<add extension=".png" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:20:00" location="Client" />
<add extension=".css" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:20:00" location="Client" />
<add extension=".js" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" duration="00:02:00" location="Client" />
</profiles>
</caching>
<staticContent>
<clientCache cacheControlMode="UseExpires" cacheControlMaxAge="1.00:00:00" httpExpires="Sat, 11 June 2016 00:00:00 GMT" cacheControlCustom="public" />
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="text/javascript" />
</staticContent>
<urlCompression doDynamicCompression="true" doStaticCompression="true" />
<httpCompression dynamicCompressionEnableCpuUsage="80" />
<httpProtocol allowKeepAlive="true">
<customHeaders>
<add name="ETag" value="0" />
</customHeaders>
</httpProtocol>
</system.webServer>
Questions::
1)When I am checking the output via chrome developer tools network sections it is always taking images from server and not cache.I always get Status 200 response.I am using around 12 images in a sprite and they will never change.
2) I am not able to figure out how js and css bundles are cached.Every round trip again loads the complete bundle from server.Sometimes I get 304 response but I am not able to understand this fluctuating behaviour.
I am not able to drill down the issue.I have searched everywhere including this site but not able to put the optimum config settings to achieve the output.
Kindly someone help
I am new to trying to use AD FS and I have been running in circles.
Trying to make a claims aware application
The organization handles its own authentication
I have gotten my test application to verify authentication but it seems wrong.
Create new application in Visual Studio
Choose Web -> Visual Studio
Choose .Net Framework 4.5
Select ASP.Net MVC 4 Web Application
Add Reference to System.Identity
Add Reference to System.Identity.Services
Edit my web.Config file
in the configsection -- add the following
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
then add
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="ida:FederationMetadataLocation" value="https://fedtest.xxxxxxxx.com/FederationMetadata/2007-06/FederationMetadata.xml" />
<add key="ida:Realm" value="https://myappNameHere.xxxxxx.com" />
<add key="ida:AudienceUri" value="http://myappNameHere.xxxxxxx.com" />
<add key="loginUrl" value="~/Home" />
</appSettings>
Then add
<location path="Home">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
<location path="Logout.html">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Then add
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authorization>
<deny users="?" />
</authorization>
<authentication mode="None" />
</system.web>
Then add
<identityConfiguration>
<audienceUris>
<add value="http://myappName.xxxxxx.com/" />
</audienceUris>`
<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
<authority name="http://fedtest.xxxxxxx.com/adfs/services/trust">
<keys>
<add thumbprint="12345567890asdasfsdgdfhdfgjdf123124" />
</keys>
<validIssuers>
<add name="http://fedtest.xxxxxxxx.com/adfs/services/trust" />
</validIssuers>
</authority>
</issuerNameRegistry>
<securityTokenHandlers>
<add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</securityTokenHandlers>
<certificateValidation certificateValidationMode="None" />
</identityConfiguration>
</system.identityModel>
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="true" />
<wsFederation passiveRedirectEnabled="true"
issuer="https://fedtest.xxxxxxxxx.com/adfs/ls/"
realm="https://myappName.xxxxxxxx.com/"
reply="https://myappName.xxxxxxxxx.com/"
requireHttps="true" />
</federationConfiguration>
</system.identityModel.services>
Why do I think all this is wrong?? Well I got all those lines of web.config from the following steps...
go back to step 5 and do the following
Under Tempalte click web
chose the only option --- ASP.NET Web Application
Wizard comes up and click the 'change Authentication'
Choose Organizational accounts
change drop down to 'On Premises'
fill out 'On-Premises Authority'
Fill out 'App ID URI'
Look at web.config
But using the application that those steps produce will create a redirect loop that I have never been able to trouble shoot.
So -- suggestions on what I am doing wrong. It can't be considered right to generate the web.config in a standard way and paste it into a previous version to get it to work.
Refer: Use the On-Premises Organizational Authentication Option (ADFS) With ASP.NET in Visual Studio 2013.
In terms of the redirect loop. the usual reason is that for your ADFS RP, you configured the endpoint without a trailing slash.
Add the missing "/" and ensure it matches the string in your web.config.
Enable SSL in your application and set the SSL URL as the default in your web properties.
Okay -- what the answer ended up being...
1) I started down this route because i kept getting a redirect loop that I thought was caused by the web.config.
It wasn't the web.config.
2) So create the the application as you are supposed to in VS 13 -- namely go to c# -> web -> and then click the ASP.NET Web Application and set up the on premise authentication
3) My redirect loop was caused by multiple LDAP claims bundled together coming from AD FS
4) Sent my claims one rule at a time and worked like magic.
If anyone can shed light as to why this should be true I am curious.