85731

Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent

I have been attempting to run a Unit Test in visual studio for an MVC Application and continuously getting the following error:

The URL specified ('http://localhost:21496/') does not correspond to a valid directory. Tests configured to run in ASP.NET in IIS require a valid directory to exist for the URL. The URL may be invalid or may not point to a valid Web application.

The only advice around is to make sure you have a localhost address in the UrlToTest attribute like so:

[TestMethod()] [HostType("ASP.NET")] [UrlToTest(https://www.e-learn.cn/content/wangluowenzhang/"http://localhost:21496/")]

This however still doesn't run against IIS Express or IIS 7 on Windows 7 and when I delved into the event logs, found the following problem.

(QTAgent32.exe, PID 6976, Thread 15) WebSites.GetWebServer: failed to create AspNetHelper: Microsoft.VisualStudio.Enterprise.Common.AspNetHelperException: The website metabase contains unexpected information or you do not have permission to access the metabase. You must be a member of the Administrators group on the local computer to access the IIS metabase. Therefore, you cannot create or open a local IIS Web site. If you have Read, Write, and Modify Permissions for the folder where the files are located, you can create a file system web site that points to the folder in order to proceed. ---> System.Runtime.InteropServices.COMException: Unknown error (0x80005000) at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_IsContainer() at System.DirectoryServices.DirectoryEntries.ChildEnumerator..ctor(DirectoryEntry container) at Microsoft.VisualStudio.Enterprise.Common.IISHelper.GetWebServerOrdinal(Uri site) --- End of inner exception stack trace --- at Microsoft.VisualStudio.Enterprise.Common.IISHelper.GetWebServerOrdinal(Uri site) at Microsoft.VisualStudio.Enterprise.Common.IISHelper.get_WebServerOrdinal() at Microsoft.VisualStudio.Enterprise.Common.IISHelper.get_RootPath() at Microsoft.VisualStudio.Enterprise.Common.IISHelper.get_PhysicalPath() at Microsoft.VisualStudio.Enterprise.Common.AspNetHelperMan..ctor(Uri uri, BasicAuthCredential credential, Int32 frameworkMajorVersion) at Microsoft.VisualStudio.TestTools.HostAdapters.WebSites.GetWebServer(String webServerName, WebServerType webServerType, String urlToTest, String pathToWeb, String webAppRoot, BasicAuthCredential credential, Context context, WebSiteConfigurationType webSiteConfigType, Origin origin)

The next step I took was to make sure the QTAgent32 always runs with administrative privileges, along with visual studio.

I am now at a loss and cannot think of anything else to try, so do hope someone can at least point me in some direction.

Thanks

Answer1:

The tests were created in a default ASP.NET environment. In order to test the controllers but without the need to run the web application, you must delete the following attributes before the test methods.

[HostType("ASP.NET")]
[UrlToTest(https://www.e-learn.cn/content/wangluowenzhang/"http://localhost:21496/")]

    

Answer2:

I ran into the same problem today (also at this thread). I had the same errors in my event log:

(QTAgent32.exe, PID 12348, Thread 61) WebSites.GetWebServer: failed to create AspNetHelper: Microsoft.VisualStudio.Enterprise.Common.AspNetHelperException: The website metabase contains unexpected information or you do not have permission to access the metabase. You must be a member of the Administrators group on the local computer to access the IIS metabase. Therefore, you cannot create or open a local IIS Web site. If you have Read, Write, and Modify Permissions for the folder where the files are located, you can create a file system web site that points to the folder in order to proceed. ---> System.Runtime.InteropServices.COMException: Unknown error (0x80005000)

That lead me to this blog post which seems to have resolved the issue.

I just needed to go to "Turn Windows features on or off" and add IIS 6 Management Compatibility and all four subcomponents. I'm running Windows 7 Home Premium which doesn't have the Windows Authentication option, but that didn't seem to be an issue. Give it a shot and see if that resolves the issue for you.

Recommend

  • No Internet connection on emulator with company proxy
  • Facebook “Like” button error
  • permissions for Administrator accidentally removed
  • Check if user is part of administrator group - C#
  • Login Form Redirecting Back To Itself On Submit
  • Notes View: How can I show only those documents which are under the user's name in a specific f
  • How to add a new Activity type to the Task work item in TFS 2018
  • Extracting Text between sub strings in MySQL
  • Why can't I import opencv3 even though the package is installed?
  • Detect if user is in a group
  • Create a Windows Service from within Java
  • How should I, or should I use php functions considered “dangerous”?
  • EntityType as an input field?
  • Update IIS 6 IP Restrictions using command line
  • Change PCF Dev installation location
  • Get a list of members of a WinNT group
  • DirectoryInfo.GetFiles method not returning any files
  • how to increase request accept limit for asp classic
  • How to get localized Windows Administrators group name in Inno Setup?
  • Oracle - How to enforce rules on relationships depending on attributes records (simple example)
  • Is it possible to password protect an SQL server database?
  • how to get field page in PDFBox API 2?
  • PHP preg_replace_callback ignore id
  • Syntax error near unexpected token 'elif'
  • how to read a file in prolog?
  • IE6 changes DOCTYPE to a bad one
  • Connecting bluetooth device to windows phone 8 application
  • CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements
  • Unexpected token ILLEGAL while running node.js mocha test
  • nodemcu custom firmware build problems
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • iOS: Detect app start via notification press
  • Typescript - Unable to get 'import' statement to function
  • Lost migrations and Azure database is now out of sync
  • Is there any way to access browser form field suggestions from JavaScript?
  • How would I use PHP exceptions to define a redirect?
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • Web-crawler for facebook in python
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent