500 Error Running Visual Studio ASP.NET Unit Test - visual-studio
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)
Related
HTTP 500.19 Error for Dot Net 5.0 WebAPI Application [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 1 year ago. Improve this question I have a WebAPI install on a server of mine and I keep getting the following error when browsing it: HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid. I set this up using Dot Net 5.0 WebAPI and I have it installed in the latest version of IIS after publishing to a directory. Here's what my web.config looks like: <?xml version="1.0" encoding="utf-8"?> <configuration> <location path="." inheritInChildApplications="false"> <system.webServer> <handlers> <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /> </handlers> <aspNetCore processPath="dotnet" arguments=".\akmazio-api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" /> </system.webServer> </location> </configuration> <!--ProjectGuid: 3b944703-a011-4408-9581-8c919ba4ed0e--> Any thoughts on what might be causing this issue and how to resolve it?
Publish Core to IIS requires installation of .NET Core Hosting Bundle, for more information about it, you can refer to this link. If you have installed the .NET Core host bundle according to the above steps, but this problem is still not resolved. I suggest you try to deploy a core template application, I suspect there may be a problem with your application. In addition, you can also use FRT to troubleshoot this issue.
It looks like the .NET Core Hosting Bundle needed to be installed, the application needed to be modified so Swagger works correctly by commenting out the env.IsDevelopment() if statement in the Startup.cs Configure() function, the following needed to be added to Startup.cs Configure() function: app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); the public settings needed to be set to Target location: C:\publish\directory Delete existing files: true Configuration: Release Target Framework: net5.0 Target Runtime: win-x64 Deployment Mode: Self-Contained And IIS needs to be configured so that the Application Pool has No Managed Code and runs using Network Service. And voila I go to http://localhost/swagger/index.html and everything is now working correctly!
IIS8.5 Windows authentication
I am trying to create a web application in my company and I want to get the username requesting the page to define what he/she can do. My environment is a Windows 2012 R2/IIS8.5. The server is in the corporative domain. What I have tried was to enable Windows Authentication and Disabling the anonymous authentication. Here is the Web.config file with the set recommended. <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> <authentication mode="Windows" /> <authorization> <deny users="?"/> </authorization> ... </system.web> Here is the Authentication configuration sets My problem is that when I do any of the things above I get the Error 404. If I let the Anonymous Login enabled and the Windows Authentication disabled and remove the Web.config settings the application works. I need some help to guide on this. I tried to find a tutorial explaining how to do that but I could not find something that explain it clearly. I am starting using IIS. EDIT1 I have enable the detail error pages and what I am getting is the error 404.15 (URL too long). It seams that it happening when I disable Anonymous Authentication in my application. Does anyone have faced this problem? Thanks
I managed to solve it. Originally I was creating the web application with .NET framework 4.5. When I changed it to 4.0 the windows authentication worked fine and I was able to get the logged user using User.Identity.Name.
Post cache substitution doesn't work in VS2013
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.
Getting error after pushing to Windows Azure: You do not have permission to view this directory or page
I have googled for the past 3 hours and found nothing on what to do with respect to the windows azure problem: You do not have permission to view this directory or page. I did a git master push to azure and the deployment was successful. I also turned on the failed request tracing but nothing shows up but the above statement. Any ideas on how to troubleshoot this?
I just tested that if you don't deploy your main node.js file as server.js you will get this error because the web.config is specifically looking for server.js as below: <handlers> <add name="iisnode" path="server.js" verb="*" modules="iisnode"/> </handlers> To further troubleshot this issue you can access the website over FTP as described here.
AvkashChauhan's answer did lead me in the right direction but I also had to add proper rewriting rules. Here is my complete web.config <?xml version="1.0"?> <configuration> <system.web> <compilation batch="false" /> </system.web> <system.webServer> <handlers> <add name="iisnode" path="server.js" verb="*" modules="iisnode" /> </handlers> <rewrite> <rules> <rule name="myapp"> <match url="/*" /> <action type="Rewrite" url="server.js" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
I hit this error too. I am using MVC and the reason for the error was that on my layout page I had a call to an action that isn't accessible to anonymous users: #Html.Action("GetMenu", "Users") For information, I register a AuthorizeAttribute() global filter in Application_Start and my Login action is decorated with AllowAnonymous: [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public ActionResult Login(LoginModel model, string returnUrl) { My website did work previously on IIS7, but Azure is less forgiving. I fixed the problem by adding a check like this: #if (User.Identity.IsAuthenticated) { #Html.Action("GetMenu", "Users") }
The azure tools have changed a lot since this question. I recommend people using the azure-cli. But funny enough I actually don't use it after I have used it once to create a site. What I use now is just the ability to push (git) directly to a remote that is named azure, and the cli is setting that up for you. But if you don't want to install the cli you can essentially just add the remote repo (your site) manually, like this: git remote add azure https://<site-or-appservice-name>.scm.azurewebsites.net/<site-or-appservice-name>.git As you would with every other git remote.
Not specific to node.js but updating in case it helps others facing this issue for a regular web application. This can also happen if the index.html file is not present or is not found because it is in a sub-directory
I just came across this issue and in my case it was the ipSecurity configuration that was causing the issue. Just hd to go and change the allowUnlisted to true. <security> <ipSecurity allowUnlisted="false"> </security>
Simple configuration, in the azure portal go to your web app -> All settings -> application settings, under default documents add the specific name of your document which you want to view, wait for it to update, then refresh your azure link.
I had the same error message after a git push from a local repository. Solved it by opening the Azure dashboard: Web app / App deployment / deployment source and selecting local git repository as deployment source
You need to move your server.js file to your root app folder.
Lots of answers, but I didn't see one that addressed the "how do I debug this?" question, which wasn't obvious to me as someone who is new to Azure and hadn't yet used Kudu diagnostics. To see the debugging info you're looking for, just navigate to mywebsite.scm.azurewebsites.net when you encounter the "You do not have permission to view this directory or page." error on your own mywebsite.azurewebsites.net page. This will get you to the Kudu console and give you easy access to everything currently in your logs. See also the many answers to the closed-but-popular How to debug "You do not have permission to view this directory or page"? question.
IIS7.5 MVC\Forms sub-application inheritance downloads instead of executing
Hey everyone and thanks for taking the time to help. I am stuck on this problem. I have an asp.MVC application and my client want to use nopCommerce for the shopping cart. I made a test MVC application and got the sub-application working great on a simple demo. The nopCommerce virtual directory is registered as an application in IIS and it runs fine in the demo. However when I try integrating the steps into my application I get a run-time compilation error: CS0246: The type or namespace name 'Combres' could not be found (are you missing a using directive or an assembly reference?) Line 56: <add namespace="System.Web.WebPages" /> Line 57: <add namespace="System.Web.Helpers" /> Line 58: <add namespace="Combres" /> <-----Error Line Line 59: </namespaces> Line 60: </pages> The sub-application (nopCommerce) does not use Combres so I thought it was an inheritance issue so I did the location trick in the parent Web.Config file: <location path="." inheritInChildApplications="false"> <system.web> ... </system.web> </location> This got rid of the compilation error, but now there is no compilation of the file, the .aspx files just download to my computer instead of being executed. The main MVC application still runs great, I only get this downloading issue when I try to run the nopCommerce application. I am completely stumped, I am kind-of an IIS noob and am having to learn quick.
K found the answer to this. My companies platform, we use ASP.net MVC, was turning all requests with file.* into download requests. So what I wrote was working great, it was doing what is was supposed to...I just didn't know.