Post cache substitution doesn't work in VS2013 - caching

I have used Post cache substitution in a .Net4 application.
In Vs2013 when I run the application I get the following error:
"Post cache substitution is not compatible with modules in the IIS integrated pipeline that modify the response buffers"
But when I publish the application to IIS (v7) it works properly.
I searched and found the following url related to this error:
http://support.microsoft.com/kb/2014472
But it's for .NET2 and my application works in IIS.

In your appSettings section of your web.config, you should add the following entry:
<add key="vs:EnableBrowserLink" value="false" />
Turning off browser link gets rid of the error.

Related

"HTTP Error 403.14 - Forbidden" error when running the webapp

What is the reason for the error page I get when I run my webapp in Visual Studio. The URL is http://localhost:5000/
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Reason: http://localhost:5000 refers to the root of the webserver. So, for the above request, it tries to read the root folder of the server. However, IIS (express) by default doesn't allow you to view the file system. Therefore it shows above error.
Most probably you don't need to access the root of the server, instead you might need to access your webapp (ex: http://localhost:5000/myapp).
However, if you know exactly what you are doing then you can enable IIS to show the root directory (file system) using the following config in the Web.config of your application
Important: Below config should not be activated in a production or any
publicly reachable environment which is obviously a high critical
security issue.
<system.webServer>
<directoryBrowse enabled="true" />
<modules runAllManagedModulesForAllRequests="true"></modules>
</system.webServer>
Two things are usually the issue when I get this error:
1st: I never defined a standard document and changed it at some point - therefore the standard document that is automatically defined by the IIS in this case, doesn't exist
2nd: I didn't enable index search
You might want to try this. You can change those settings in the IIS settings directly.

WCF not working when debugging in visual studio but works in IE

I have a WCF that is hosted in an ASP.NET application. Suddenly, the WCF service has stopped working when i debug it in visual studio 2010. When i try to access the service, it throws the below exception.
CommunicationException was unhandled by user code. The remote server returned an error: NotFound
I have WCF tracing enabled but no errors are being logged.
The strange bit is that if i deploy the code to my QA server and access the application, the service works fine, so the code looks like not the problem.
If i also get the source code currently running in production successfully & try debugging it in my dev environment, it fails with the same error i mention above.
Any one have an idea what could be messed up in my dev environment?. I have tried both IE, Firefox & Chrome & the results are the same.
I after a very long debugging involving deleting Bin & obj folders and lots of rebuilds, i finally got this WCF service working again.
First, i suspected the service could be corrupted somehow, so i tried to update the service reference in my silverlight application but was bumped with the following error.
There was an error downloading 'http://localhost/mySite/Webservice/GetData.svc'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://localhost/mySite/Webservice/GetData.svc'.
The remote server returned an unexpected response: (405) Method Not Allowed.
The remote server returned an error: (405) Method Not Allowed.
I then browsed to the physical folder path to confirm if really my .svc file was there and indeed as expected, the file was there.
Trying to Browse to the path http://localhost/mySite/Webservice/GetData.svc in my browser bumped me with another error below.
HTTP Error 404.7 - Not Found The request filtering module is
configured to deny the file extension.
Most likely causes: Request filtering is configured for the Web server
and the file extension for this request is explicitly denied.
This made me start thinking that suddenly, IIS 7.0 has decided to block access to my .svc files.
I then added fileExtension=".svc" mimeType="application/octet-stream" to IIS, restart IIS but got the same error.
I then read on some blog i cant remember about adding <add fileExtension=".svc" allowed="true" /> under <requestFiltering> tag in file applicationHost.config located at C:\Windows\System32\inetsrv\Config, still nothing changed. Tried adding <mimeMap fileExtension=".svc" mimeType="application/octet-stream" /> under serverSideInclude in the same file, again with no luck.
Tried this http://www.adamwlewis.com/articles/iis-7-not-serving-files-4047-error still with no luck.
The following 2 steps are i think what resolved the issue.
I added a mapping for the SVC extension to ASP.NET by running ServiceModelReg.exe -i from C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation
Browsed to my .svc file in the browser and this time it looked like i had made some progress but still, i had one more error to overcome . The is bellow.
Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
I resolved the above error by registering the correct version of ASP.NET using the ASP.NET IIS Registration Tool (aspnet_regiis.exe,) as described in the link below
https://msdn.microsoft.com/en-us/library/hh169179(v=nav.70).aspx
At this point my service was back to normal as it had always been. I still haven't figured out what messed up my development machine.

Deploying lightswitch web application on the server: HTTP Error 500.19 - Internal Server Error

I have a problem with deploying the 3 tier lightswitch web application on the server.
On the local server IIS7 everything works perfect but when i deploy it to the vps which also runs IIS7 it gives me this error when i try to navigate to the page:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
I have published a package on the disc, uploaded it to the server, installed the application under Default Website with success. But when i navigate to the application it shows that error...
This is what is shown as a problem area:
Config Source
141: </system.serviceModel>
142: <uri>
143: <schemeSettings>
It is part of the web.config file. When i open it and go there i see this:
<uri>
<schemeSettings>
<add name="http" genericUriParserOptions="DontUnescapePathDotsAndSlashes" />
<add name="https" genericUriParserOptions="DontUnescapePathDotsAndSlashes" />
</schemeSettings>
</uri>
and add part is underlined which gives me further explanation of the error:
web.conf error: the element 'schemeSettings' cannot contain child element 'add' because the parent element's content model is empty.
I tried looking on the internet for the solution but no luck...
Thank you!
I have found what was the problem.
On the IIS i had DefaultAppPool selected for the application. When i changed it to ASP.NET v4.0 error was gone. This can be done in application basic settings.
Open IIS Manager, select the application, in the right column of explorer click Basic Settings, click button Select and choose ASP.NET v4.0, click Ok.
That was it for me. Hope it helps someone...

Why am I getting error 500.0 in when using IIS Express (significant debug info included)

I created a blank MVC 3 application on VS2010 SP1, and set the app to use IIS Express. When I debug, I get error 500.0 (0x80070585)
I am able to succesfuly run the app using the VS dev server
I have set the app directory to Full Permissions for Everyone, just to eliminate all possibility of security issues. I have further verified that IIS express is able to hit the web.config by confirming it using SysInternals ProcMon. ProcMon does not show the IISExpress process attempting to read from any other files in my application directory.
I have followed the suggestions in the following question, but it does not give me any better information. HTTP 500 Internal Error - IIS websites
No logs are generated in the IISExpress directory in either the Logs or TraceLogs directory, but a log is created in Temp, however it is not very useful.
Successfully registered URL "http://localhost:62017/" for site "MvcApplication1" application "/"
Registration completed for site "MvcApplication1"
Request ended: http://localhost:62017/ with HTTP status 500.0
Request ended: http://localhost:62017/ with HTTP status 500.0
Request ended: http://localhost:62017/ with HTTP status 500.0
There are no messages I am able to find in the Event Viewer
**Updates : **
Disabled firewall, no change
Ran IISExpress via command line, no change
I had the same issue last week, the app running perfect in dev web server from VS Studio. But in IISExpress anytime HTTP Error 500. My solution on this time was:
close VS Studio - solution set with IISExpress
got to: /Document/IISExpress/config/ in your profile
rename or delete applicationhost.config
open your solution in VS Studio
a Dialog will fire up from IISExpress - this will set a fresh config.
try to run your web app
You may have some mime code in the Web.Config file like this:
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
if so, you should remove mimeMap before adding like this:
.
..
...
....
</system.web>
<system.webServer>
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
....
...
..
.
This may be related to a conflict between the IIS Express applicationhost.config and your web.config.
A mimeType was added to my local web.config that was already present in the applicationhost.config and IIS Express started serving many 500 errors.
You may also notice this error in your Windows Event Log, "The directory specified for caching compressed content is invalid. Static compression is being disabled."
More info: http://blog.degree.no/2013/04/the-directory-specified-for-caching-compressed-content-is-invalid-static-compression-is-being-disabled/
I removed the mimeTypes from the web.config and the issue was resolved.
applicationhost.config location: C:\Users\[User]\Documents\IISExpress\config
reinstalling iis express appears to have resolved this problem
Are you using any PLINQ(.AsParallel) or Parallel.For or similar methods? I've found that the AggregateExceptions they throw aren't handled well by MVC (In my case, I got a blank 500 page and nothing in Logs/Event logs).
I identified the problem by paying attention to the "First Chance" exceptions which are logged in the Debug output window in VS. Try running the site, waiting for it to error, clearing the Debug window and the reloading the page. Do you see anything useful?
There might be a problem with your config files, specifically web.config and applicationhost.config.
The only way I know how to diagnose this, is to publish a build to regular IIS, and in IIS Manager check the "Error Pages" module of the Site. If it is indeed an issue with those config files, you'll get a popup here with something along the lines: "Cannot add duplicate entry of type …". Google accordingly.
If the "duplicate entry" is of type "error", you can try adding the following element below httpErrors:
<remove statusCode="404"/>
That is, assuming you have an Error element below the HttpErrors with statusCode 404. (I had once.)
In my case the issue was caused by using windows authentication + firefox + wrong domain login with insufficient permissions.
Details:
My dev machine is using windows domain "domA", the application will run in an environment accepting logins from domain "domA" and "domB". While on the webserver both will work, on my dev machine only my account in "domA" has sufficient permissions to access all files of the application. In IE "domA" is used by default while in FF I get a login dialog where I did login with my account from "domB".
Confusing issue I know, but maybe there is someone else having the same situation. At least it will help me the next time I run into it. :)
Just in case catches someone else out, I had similar error but the issue was I had updated my web.config and there was an extra ">" character where it should be.. so malformed web.config file can cause the same behaviour.

500 Error Running Visual Studio ASP.NET Unit Test

I have the following method in my unit test project:
[TestMethod]
[HostType("ASP.NET")]
[UrlToTest("http://localhost:3418/Web/SysCoord/ChooseEPA.aspx")]
[AspNetDevelopmentServerHost("%PathToWebRoot%")]
public void TestMethod1()
{
Page page = TestContext.RequestedPage;
Assert.IsTrue(false, "Test ran, at least.");
}
I'm getting this exception:
The test adapter 'WebHostAdapter' threw an exception while running test 'TestMethod1'. The web site could not be configured correctly; getting ASP.NET process information failed. Requesting 'http://localhost:3418/SysCoord/VSEnterpriseHelper.axd' returned an error: The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.
The page works as it should in a browser at the url: http://localhost:3418/Web/SysCoord/ChooseEPA.aspx.
This physical path is: C:\ESI\HR_Connect2\BenefitChangeSystem\Application_DEV\Web\SysCoord.
Any ideas would be appreciated.
Update 1
Added the following to my web.config file per this article. Also made the web.config writable and killed/restarted the development web server. No change in behavior.
<location path="VSEnterpriseHelper.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
Update 2
Changing the AspNetDevelopmentServerHost attribute to the equivalent of [AspNetDevelopmentServerHost("%PathToWebRoot%\solutionfolder\webfolder", "/webfolder")] resolved the 404 problem.
Unfortunately the test began to return a 500 error instead. Progress, but not much. Trial and error with a clean project led to the conclusion that references to custom classes in the of the web.config were causing the problem.
For example:
<profile enabled="true" defaultProvider="MyProfileProvider">
<providers>
<add name="MyProfileProvider" connectionStringName="ProfileConnectionString" applicationName="/MyApp" type="System.Web.Profile.SqlProfileProvider"/>
</providers>
<properties>
<add name="Theme" type="String" defaultValue="Default"/>
<add name="LastLogon" type="DateTime"/>
<add name="LastLogonIp" type="String"/>
<!--
<add name="EmployeeSearchCriteria" type="MyApplicationFramework.Profile.EmployeeSearchCriteria"/>
<add name="DocumentSearchCriteria" type="MyApplicationFramework.Profile.DocumentSearchCriteria"/>
-->
</properties>
</profile>
With the criteria types above commented out the test ran fine. With them uncommented, the 500 error was returned.
Anyone had a similar problem in the past?
I've had this problem before and at that point gave up after reading all I could google about it (including this thread).
The solution turned out to be simple in my case. All I had to do was not use ASP.NET test attributes and simply test the MVC project as a DLL.
Step 1
Remove the extra attributes from the test.
[TestMethod]
public void TestMethod1()
{
Page page = TestContext.RequestedPage;
Assert.IsTrue(false, "Test ran, at least.");
}
Step 2
In Code Coverage, uncheck the MVC Project and add the MVC Project's DLL manually.
Voila, it get instrumented as a normal assembly, no errors, doesn't spin up the Development Server, also doesn't fail the Team Build.
I found that using vs2010 I am not restricted to just 4.0 applications. I DID however find that if testing a web application and you are using the old System.Web.Extensions version redirect you may get an error. Removing the following section from the Web.config file fixed my issue:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50727">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Good luck.
I was getting the same problem as you, however my experience was a little different.
I am on vista x64, my developers are in xp x64...they haven't been having any issues at all. I just upgraded and could not run any unit test for a asp.net MVC project. I was receiving the same 500 error you were receiving.
I turned off code coverage, everything magically started working.
Based on your evidence I would guess that a reference to whichever assembly contains MyApplicationFramework.Profile.EmployeeSearchCriteria is missing from either the unit test project or the web project - though I would really think that you would only require the reference in the web project but I'm not knowledgeable about how the VS web server behaves when used as part of a unit test.
I ran into a similar issue testing a webservice where the project is .NET 3.51. I was getting a IIS 500 error.
I removed the old assembly bindinds as commented by Hal Diggs and it worked.
I setup a default unit test which popped up with the error, that brought me here. I just removed the following (below). Then clicked debug current context and boom, fine :S.
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\\Inetpub\\....]
I got the same error message while unit testing a web app with Visual Studio 2010. The only difference is that i was using IIS, ie i ommited the [AspNetDevelopmentServerHost("%PathToWebRoot%")] directive.
I suspect the problem lies in the fact that i was using IIS version 5.1. More here:
http://ibsta.blogspot.com/2011/01/unit-testing-fun-under-visual-studio.html
I have faced same problem with unit testing.
And found the problem reason and also solve it.
The problem is only with access rights for the directory.
In my case I have installed VSTS on the different drive(d) then default.
So only to give the full access rights to the user PCNAME\ASPNET for whole directory \Program Files\Microsoft Visual Studio 9.0.
I m using the windows XP but if u are using window server then give access rights to the user NetworkServices.
By this solution i have solved my problem.
Hope u find something useful from this Answer.
Thanks,
Priyesh Patel
Comment out the whole bit of web.config like this
<!-- <location path="VSEnterpriseHelper.axd">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web> </location> -->
It worked for me
Make sure your web application is targeted to Framework 4.0. If you are trying to test a
2.0, 3.0 or 3.5 project, you will get the (500) Internal Server Error.
I experienced the same problem. Then I checked the properties of both the web project and the unit test project. And found that target framework was set different from each other. I set the target framework of both the project to .Net framework 4 (in my case). Finally ran the test method again and it worked.
Thanks.
For me it was Resharper that caused this problem. Once I suspended it (Tools -> Options -> Resharper -> General -> Suspend) everything worked.
(using VS2010SP1 and Resharper Ultimate 2016.1.2)

Resources