Why does setting shadowCopyBinAssemblies="false" have no effect? - c#

I'm trying to turn off shadow copying in IIS to improve performance in production.
But adding that in my web.config has no effect. Here's my web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<hostingEnvironment shadowCopyBinAssemblies="false" />
</system.web>
</configuration>
When I hit the URL it takes just as long the first time, and
files still appear in
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
so it appears to have no effect.
IIS 7.5 and Windows 7. I'm testing with a tiny Hello World ASPX page.
Any ideas why this isn't working? Is this setting overridden somewhere?

Related

.NET 4.6.1 and IIS7 - Cannot upload large files from WebAPI2 endpoints

I am trying to upload files using my .NET application. I cannot upload large files and it responds with 413 - Request Entity Too Large.
I tried solutions that suggested changing maxRequestLength and maxAllowedContentLength in web.config. Also changed the uploadReadAhead setting in IIS. I still am unable to upload the files.
The project has two web configs. Parent directory web config has the following settings:
<system.web>
...other lines
<compilation targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1" maxRequestLength="2147483647" executionTimeout="999999" />
<customErrors mode="Off" />
</system.web>
The web config in the inner Portal directory has:
<system.web>
...other lines
<httpRuntime targetFramework="4.6.1" requestValidationMode="2.0" executionTimeout="999999" useFullyQualifiedRedirectUrl="true" maxRequestLength="2147483647" />
</system.web>
<system.webServer>
...other lines
<httpRuntime targetFramework="4.6.1" requestValidationMode="2.0" executionTimeout="999999" useFullyQualifiedRedirectUrl="true" maxRequestLength="2147483647" />
</system.webServer>
How do I fix this ?
Thanks.
Hum, that should be fine. On the other hand, seems to me that adopting some kind of nice up-loading library that up-loads in chunks would be better. This tends to "less freeze up" the user interface and also tends to not freeze up the web server either.
I mean, for a user to up-load a big file, then they are going to be stuck watching the screen - nothing occuring. With a nice up-loader library, then only small chunks are sent up, you get a progess bar, and you have un-limited up-load file sizes.
However, you could try in the main web.config,
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2048000000"/>
</requestFiltering>
</security>
</system.webServer>
So, you could try adding above under system.webServer

How to restrict specific pages to Certificate Authentication?

In my ASP.NET web-application I have created Default.aspx (set as my start page), and a new folder called SmartCard with WebForm1.aspx inside of it. How do I configure Web.Config to prompt user for Certificate upon visiting SmartCard/WebForm1.aspx but NOT when Default.aspx loads?
In the accepted answer of this question:
if your app is hosted in IIS then simply add (in web.config) a section that says client certificate is required for those pages. THe browser will then ask the user for a cert.
From the above answer, I looked some more on StackOverflow and found this. From their accepted answer I put the following section in Web.Config:
<location path="SmartCard">
<system.webServer>
<security>
<access sslFlags="SslRequireCert" />
</security>
</system.webServer>
I then modified applicationHost.config in C:\Windows\System32\inetsrv\config (or appropriate directory for your install) and change the following line:
<section name="access" overrideModeDefault="Deny" />
to:
<section name="access" overrideModeDefault="Allow" />
However, I still get prompted for a Certificate on site load. I first get the following screen:
After clicking "Continue to this website" I then get prompted to selected a Certificate when Default.aspx loads. However, I only want to get prompted to selected a Certificate when SmartCard/WebForm1.aspx loads!
ANY help is greatly appreciated!
Here are my site settings in IIS-7:
SSL settings:
Site Bindings:
*MyDevCert is self-signed
Update:
I created a new Web.Config file inside of SmartCard directory with the following:
<?xml version="1.0"?>
<configuration>
<security>
<access sslFlags="SslRequireCert" />
</security>
<system.web></system.web>
</configuration>
I then removed the 'location' tag from base Web.Config.
Base Web.Config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<identity impersonate="false" />
</system.web>
</configuration>
However, I still get "There is a problem with this website's security certificate" screen and I get prompted for certificate once I click "Continue to this website"
From what I'm seeing, you can only have a single value for sslFlags.
See http://www.iis.net/configreference/system.webserver/security/access
And https://msdn.microsoft.com/en-us/library/ms689458(v=VS.90).aspx
The sslFlags attribute can be one of the following possible values. The default is None.

Cannot open VS 2010 solution file in Xamarin Studio (MonoDevelop)

I have built an ASP.NET Web Service in C# and and I need to run this on Linux. After googling, I found out that it's possible to execute ASP.NET web service on Linux using Mono Develop. But when I try to open my Solution File in Mono (Xamarin Studio) it gives me an error:
Error while trying to load the project.
What am I doing wrong? Or maybe what is the best solution to run ASP.NET Web Service on Linux?
EDIT:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation defaultLanguage="C#" debug="true">
<assemblies>
</assemblies>
</compilation>
<customErrors mode="RemoteOnly">
</customErrors>
<authentication mode="None">
</authentication>
<authorization>
<allow users="*" />
</authorization>
<httpHandlers>
</httpHandlers>
<trace enabled="false" localOnly="true" pageOutput="false" requestLimit="10" traceMode="SortByTime" />
<sessionState mode="InProc" cookieless="false" timeout="20" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
<pages>
</pages>
</system.web>
</configuration>
First of all, it can fail for a lot of reasons, so add a bug report into Xamarin's Bugzilla. But try initially to start Xamarin Studio, choose create new Asp.Net solution and then replace with your files in the .vcproj file (you can use a simple xml editor like gedit or Notepad++).
Depends on your application kind, I found that simple web pages/web services work but is not using IIS, but is using XSP4 (their custom C# written IIS-like web server) which sometimes is slow.
If you need simply to make some business logic to run fast on Mono and to not have configuration hassles, I would recommend to you .Net remoting. This is a low-overhead solution and I found it working even in combination with binary serialization.

Validation of viewstate MAC failed, tried generating machine key

Server Error in '/' Application.
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
I've looked through countless of previous questions and I haven't managed to get it working.
I've edited my web.config file and included a generated key at no success.
Web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<machineKey validationKey="E91A16E07A8D628F1F1397962336B0C63B6DC45B8EB3D16BBD5E5761DD8AE462C04C1CC215904FF0353E84EF8194B48682114C72CF8E10F5295E5ADF36DBC520" decryptionKey="EFA118DF00BFB8206F24A1BB4AF7D18FBD6A605B44789E9048D8127FFF950A09" validation="SHA1" decryption="AES" />
<httpRuntime />
<pages enableViewStateMac="true" />
<customErrors mode="Off" />
<compilation targetFramework="4.0" debug="true" />
<authorization>
<allow users="*" />
<deny users="?" />
</authorization>
</system.web>
</configuration>
This happens when I postback to another page!
Instead of using <form action="..."> to perform a cross-page post back, try changing your submit button to read <asp:Button runat="server" postbackurl="...">. Using the PostBackUrl property is the officially supported way to perform a cross-page post back, as it sets a flag in the request telling the destination page to ignore the __VIEWSTATE field.
The main problem lies in the Application Pool of your website.Configure your website to use the proper .NET Framework version (i.e. v4.0) under the General section of the Application Pool related to your website.
Under the Process Model, set the Identity value to Network Service.Close the dialog box and right-click your website and select Advanced Settings... from the Manage Website option of the content menu. In the dialog box, under General section, make sure you have selected the proper name of the Application Pool to be used.
Your website should now run without any problem.Hope this helps you overcome this error.

Validation of viewstate MAC failed.Application hosted by a Web Farm, ensure <machineKey> configuration [duplicate]

This question already has answers here:
Asp.net Validation of viewstate MAC failed
(17 answers)
Closed 9 years ago.
net 4.0 frame work,
I had made many website in this frame work but never get such error
"Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster."
I think so this error is caused because of use of cookies as only in this website i had made use of cookies.
Another one thing i used to get this error very rarely almost 2twice a week
I had read many solutions for this but very rarer for 4.0
solution readed such as putting
<machineKey validationKey="6628ECBFB40F6F852AB543C23C0B83C1679C5AAE35AD72FACF5B9F4FDB70AA1F648A1D5877CE1F9D69F08BAD919BFBAC0976D9119B8F32CFB80814E4E943F8EE" decryptionKey="42F45B378301126EB4CCBA16995304263754EF116E08A81003A936CC04B7537F" validation="SHA1" decryption="AES" />
in web config
OR Adding
<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never" />
in webconfig
But where should i add in my above web config
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="Conn" connectionString="Data Source=abc; Initial Catalog=alfadesi_trikon;User ID=abc;Password=abc" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<globalization culture="en-AU" uiCulture="en-AU" />
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Windows"/>
<customErrors mode="Off"></customErrors>
</system.web>
</configuration>
you can add your machine key in system.web element.
for e.g.
<system.web>
<machineKey validationKey="1234567890123456789012345678901234567890AAAAAAAAAA"
decryptionKey="123456789012345678901234567890123456789012345678"
validation="SHA1" decryption="Auto" />
</system.web>
If you don't want to put a machinekey in the web.config for each application, you need to put it in machine level web.config for each .Net Framework version.

Categories