Config File referencing wrong location .Net application - c#

I am inheriting a .NET application. For starters I have copied the source to my machine and opened the solution with Visual Studio. Upon running the project I see the following error:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information:
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x80070003
Config Error Cannot read configuration file
Config File \\?\path\not\on\my\machine\web.config
The problem seems to be that the path referred to by "Config File" is not the path to the file on my machine. The path seems to be from an IIS server on which the app was deployed.
I've seen others with similar problems, but in my search I have been unable to find this reference so that I may update it.
Visual Studio (2015) itself seems to respond to changes I make in web.config, particularly when I change this <compilation debug="true" targetFramework="4.0"> from true to false.
How can I change my project set up to allow the application to run on my machine?

I was able to fix the problem. Under the project directory there was a file .vs\config\applicationhost.config. From there I changed the physicalPath attribute on the virtualdirectory tag that referenced the wrong place.

Related

Build ASP.NET Web Api to a different output directory

I have a ASP.NET web api project, the api has lot of dependencies to other dlls so we have placed all the dlls in a specific folder. If I point output path of the web api to that output directory and execute in IISExpress it gives following error
Parser Error Message: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located.
If we see file location of the error it is still pointing to WebAPI_SourceCode_Directory\web.config and not my output folder. But output folder has web.config file. How can I make the web app to run from output folder using IISExpress
It is not recommended to change the output directory of an asp.net application due to IIS security restrictions.
However you can still hack your way through it by changing config files appropriately, see here
As per MSDN article, when you compile a Web application the compiled code is placed in the Temporary ASP.NET Files folder
To find this Temporary ASP.NET Files folder check my post here
do not use IIS express for development, use a proper IIS instead. This way you will iron out any production issues from the beginning.
Whether your API has a lot of dll dependencies or not, it makes no difference. The API needs to know where to get them from and I wouldn't change the default behavior. They will be in the bin folder like all the other dependencies when you build the project.
To deploy the API even in a local environment, use the Publish method to a local folder, then build an IIS application pointing to that folder.
That's all you need to do, so why complicate things? You can still publish in debug mode, you can still connect your Visual studio to it and debug it properly. There is literally zero need to fight the default way of doing things.

How to solve 'Could not load file or assembly 'Microsoft.AI.Web' or one of its dependencies' error?

I upload my asp.net file in webserver. First it shows
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration
Then I add <customErrors mode="Off"> in web.config file.
After that when i run it shows the following error.
Could not load file or assembly 'Microsoft.AI.Web' or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AI.Web' or one of its dependencies. The system cannot find the file specified.
I upload my projects file completely such as bin, css, js, images and forms.
First time I am uploading in web server. Please tell me what should I do.
I had this exact same error while deploying an app containing application insights to production (worked on acceptance weirdly, but oh well) yesterday. Somehow the project was incorrectly configured to not copy a bunch of references (including the Microsoft.AI.Web reference).
The solution proved quite simple:
Install-Package Microsoft.ApplicationInsights.Web
This installed a new version of application insights and fixed the references. Alternatively, I would suspect that a reinstall of that package would do the same trick.
You could follow the below steps to solve the issue:
Open IIS.
Right click the 'Default Web Site'. Go to 'Manage Web Site' > 'Advanced Settings..'
Check the 'Physical Path' value. It should be 'C:\inetpub\wwwroot'.
Note: The above steps would work if you have published your project as an Application under the 'Default Web Site' in IIS. In case you have publish your project as a different web site, you could try the similar steps to point it to your project and not to 'C:\inetpub\wwwroot'
You must have your reference set to "copy local" when deploying your website.
Check this answer
I get this when running my site with Target .Net Framework 4.5.2 but not when running with 4.6
I had similar issues. It started after I uninstalled an instance of visual studio 2017. I wanted to revert back to VS2015.
Cause
It was probably caused by conflict in .Net Framework.
My Solution
I Edited changed all the .Net Framework of my Projects to point to the same framework (.Net 4.6 framework)
I cleared the bin folder of the project.Make sure this is selected for the bin folder to be visible
I rebuilded the projects and the error stopped.
Just Remove the following tag line from web.config file
ApplicationInsightsWebTracking

Opening webapi project giving an error

I am getting
"Creation of virtual directory http://localhost:30852/ failed with the error: Filename: redirection.config Error: cannot read configuration file"
while opening webapi project. Someone else created on their machine and I am downloading from TFS. It works fine on their machine.
I have installed latest .net framework and I have IIS installed on my local machine.
I already tried opening Visual Studio as admin, but no use.
There could be a couple of things gone wrong here.
1) I've seen the problem occurs that TFS ignores an item from checking in or completely removes them from the being part of source control.
If this is the case, let your college re-add then to the source control and commit.
2) check on your college's machine. If the file is actually marked as part of the commit and if it's committed. If both seem fine, make sure the version on your local repo is correctly pulled from TFS.
Depending on what version control (git or TFS) you are using your files are by default located at: C:\Users\%username%\Source
3) There is a difference in the redirection config you and your college are using. You might already have the other application registered at this path in your application host config.
The config can be found at Documents\IISExpress\config simply compare this config with your colleges. If you have a conflicting configuration you can change it to a different port.
As last resort, you could simply copy over the redirect config from your college and see if this fixes the problem.

"There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined"

I am developing a project using vstudio 2015, when i tried to run it on another system i am getting following error, tried many solutions available here but unable to get rid of this.
Note: another systems has same configurations as of mine.
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information:
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x80070003
Config Error Cannot read configuration file
Config File \?\D:\Visualstudio Projects\SPARC\SPARC\web.config
Requested URL http://localhost:1396/
Physical Path
Logon Method Not yet determined
Logon User Not yet determined
Request Tracing Directory C:\Users\Syeds\Documents\IISExpress\TraceLogFiles\
Config Source:
-1:
0:
More Information:
This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.
If you see the text "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined", this error is because you are running a .NET Framework 3.5-based application in .NET Framework 4. If you are running WebMatrix, to resolve this problem, go to the Settings node to set the .NET Framework version to ".NET 2". You can also remove the extra sections from the web.config file.
Warm welcome for suggestion and answers,
Thanks & Regards.
Restarting visual studio might help on this.
This usually happens when you have invalid configs in your {solutions_dir}/.vs/{project_name}/config/applicationhost.config. This file contains machine specific configuration.
.vs/* directory should be added to your gitignore if you are using git. So the contents of this directory never gets pushed to the main repo.
If this will not work.
Open the file {solutions_dir}/.vs/{project_name}/config/applicationhost.config.
Go to the sites section
Check the application if it matches the physical path that is configured for each site applications. IISExpress will look use the phyiscalPath as its based directory per application.
In my case Actual issue was directory, to solve it what i did was creating same folder directory (as in my system) into other system.
IIS was trying to find webconfig in D:\Visualstudio Projects\SPARC\SPARC\
So, i created folder "Visualstudio Projects" in D: and then pasted the project there and it worked..
There was no any problem in web.config or applicationhost.config or in any of the IIS configuration.
I have this issue when I have same project file (Solution file) in two separate folder. The project properties was same and port number for IIS Express was same. The issue is resolved when I created new virtual directory.
Change project URL in Project>Properties>Web>Servers>Project Url.
Please create new Virtual Directory.
Try open your web.config and search for a tag named <scriptResourceHandler>
Can you find more than 1 result?
If yes, try merging the two "scriptResourceHandler" to one.

Having problems deploying my .Net web application via FTP

In the past, I've had no problems uploading my web site to my hosting provider but now I'm using .Net 4.5 with Nuget packages and I'm getting errors. Oh and now it's a web Application.
When I look at my file structure, I have 'MySite' as the parent folder, then under that I have the 'Packages' folder (which I assume is where the Nuget files I downloaded are installed). At the same level as the Packages folder, I have another 'MySite' folder which I uploaded to the server via FTP.
Now I'm thinking that the server would need the Packages folder but I don't know where to put it. I also thought about using the Publish feature in VS 2013 but need a .publishsettings file from my hosting provider which I do not have.
Surely there is a way to just transfer the files via FTP?
At the moment I'm getting the following error:
Parser Error Message: Could not load type 'MySite.Global'.
Line 1: <%# Application Codebehind="Global.asax.cs" Inherits="MySite.Global" Language="C#" %>
I cannot see any problem with my Global.asax.cs file at all.
please try this:
Could not load type 'XXX.Global'
"Could not load type [Namespace].Global" causing me grief
I guess the problem is because some dll is missing or your pool of IIS is not configured corretly.
Based on error I think .net version is not property set in application pool.

Categories