error ASPCONFIG: Unable to open configSource file - asp.net-mvc

Our .Net Framework 4.8 web application suddenly began to generate the following build-time error on our team city build server:
error ASPCONFIG: Unable to open configSource file ‘sessionState.config’.
Our web.config references an external session state file:
<sessionState configSource="sessionState.config" />
The project is under active development, however no related changes have been recently made to the application. We initially thought it was a configuration issue on the build server, however we realised that we could replicate the same issue on our development machines if we "Published" the project and ticked the option to "merge all outputs into a single assembly". We published to a local file to replicate what was happening on our build server.
Modifying the Build Action of the sessionState.config file from None to Content removed the problem, but this had the effect of copying our sessionState.config file to the deployment package, which we didn't want.

We spent many hours trying to investigate this problem and finally decided to try uninstalling recent Microsoft Updates. This resolved it! I'm posting this here in the hope that it will save at least one other person the time we spent.
This specific October 13, 2020 update was the cause, however, it didn't come up for us when we searched https://support.microsoft.com/en-us/help/4578974/kb4578974-cumulative-update-for-net-framework
After you apply this October 13,
2020 Security and Quality Rollup for .NET Framework 4.8, some ASP.Net
applications fail during precompilation. The error message that you
receive will likely contain the words “Error ASPCONFIG.”
An invalid configuration state in either the "sessionState,"
"anonymouseIdentification," or "authentication/forms" sections of
"System.web" configuration. This might occur during build-and-publish
routines if configuration transformations leave the Web.config file in
an intermediate state for precompilation.
Note their spelling error in anonymousIdentification
The solution is to add this appSettings key to your web.config
<configuration>
<appSettings>
<add key="aspnet:DisableAppPathModifier" value="true" />
</appSettings>
</configuration>
The article notes that setting the value to either "true" or "false" will avoid the issue. It was recommended to set this value to "true" for sites that use cookies for the session state id.
We use cookies, so added this to our web.config with a true value, and it resolved the problem.

Related

Getting "A default document is not configured " error when deploying ASP.NET MVC application on IIS 7.5

Developing an ASp.NET MVC 5 application. Runs without an issue on the development machine (Windows 7 x86). When I tried to deploy it on IIS 7.5 (Win Server 2008 R2 64 bit) I got 3 errors:
Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
I fixed this issue by removing targetFramework="4.5" from
<compilation debug="true" targetFramework="4.5">
The tag contains an invalid value for the 'culture' attribute.
I don't know why but compliant was about the following entry:
<globalization enableClientBasedCulture="true" culture="az-Latn" uiCulture="az-Latn" />
After removing culture="az-Latn" uiCulture="az-Latn" this problem also got solved. But I don't think this is a proper way of solving that, so it'd be good to know the right solution.
Now the third error is the one that's taken all my day. After solving the above two problems now I get the error in the image:
The best solution that seems to work for almost everybody is to add the following entry:
<modules runAllManagedModulesForAllRequests="true" />
But I already have it in the config file. IIS was missing URLRewrite module so I installed it manually.(Don't know if this has anything to do with it though). Didn't help. Enabled 32 bit Applications. Didn't help. What else should I try?
There are two possible solutions
Make sure the application pool that is running your site is set to version 4. It's likely defaulted to v2 which will give you all the errors you mentioned in the question.
Re-register your framework with this command:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -i
I'd also revert those changes you have made (e.g. put the targetFramework attribute back in)

Relative paths in CSS not valid when using MVC w/Bundles

I've been developing a MVC5 web application for several months. I've published to each of 3 servers used for development, testing and the intended public server. Everything has been tested by a team of a dozen beta testers and a decision was made to go live with the web app this weekend.
Prior to publishing the web app to the live (public) host I modified the web.config to disable debug mode for the public site. After publishing, all kinds of problems cropped up related to missing CSS and JS resources.
After reading a lot of articles regarding Bundles and 404 errors, I found one that hinted to add the following to Web.config:
<modules runAllManagedModulesForAllRequests="true">
<remove name="BundleModule" />
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />
</modules>
This resolved the 404 issues for the StyleBundle and ScriptBundle configurations, but now I have 404 errors for images that previously worked fine. I'm not sure of the best way to resolve these. I don't want to relocate the images and I don't want to edit the CSS since these are distribution files (jQueryUI, ThemeRoller, DataTables, etc). I want to leave their distribution folder structure and original source files (CSS and JS) unmodified.
An example of the problem.
DataTables distribution is in my ~/Scripts folder:
/Scripts/DataTables-1.10.2/
/Scripts/DataTables-1.10.2/media/css
/Scripts/DataTables-1.10.2/media/images
/Scripts/DataTables-1.10.2/media/js
Bundles configuration:
bundles.Add(new ScriptBundle("~/bundles/DataTables").Include(
"~/Scripts/DataTables-1.10.2/media/js/jquery.dataTables.js"));
bundles.Add(new StyleBundle("~/bundles/DataTables.css").Include(
"~/Scripts/DataTables-1.10.2/media/css/jquery.dataTables.css"));
jquery.dataTables.css contains references to ../images/someimage.png and with Web.config debug mode enabled this works flawlessly. Now that debug mode has been disabled and Bundles are minifying/combining, I am getting 404 errors:
http://example.com/GenericError.htm?aspxerrorpath=/images/someimage.png"
It seems as though the image URL is now assumed to be relative to /Bundles/ - though I'm not positive.
There must be an additional configuration I'm missing. Can someone point me in the right direction?
EDIT
Raphael's comments on this question and his URL to another similar SO question did not help to resolve this problem. Sean's recommendation of BundleTransformer seems like it might work but I don't find any documentation on how to install this package.
See my answer at:
CSS/JS bundle in single file in mvc when publish with release option
It deals with this exact issue and the options you have to resolve it.

Error - The pre-application start

I am currently editing a project that was opened from a source control at my business. When trying to debug locally I get the error
Validating Web Site
: Build (web): The pre-application start initialization method Start
on type System.Web.WebPages.Deployment.PreApplicationStartCode threw
an exception with the following error message: Access to the path
'C:\Users\gary\Documents\Visual Studio 2010\WebSites\DOISAdminPortal\'
is denied..
Ive done some research and a lot of people say to delete the
add key="webpages:Enabled" value="true"
from the web.config file. It was never included in the config file so that shouldn't be the issue.
Anyone have any suggestions??
The files which were contained in the VS 2010 folder needed to be given permissions to the iis express user iis_iusrs. once this was done I was able to access all files in the directory and was able to debug the page.
Short Answer: Try turning off impersonation for local testing.
For my case, our web.config had the following line:
<identity impersonate="true" userName="DOMAIN2\admin" password="12345"/>
under the </system.web> section.
This impersonated identity functioned on the production server, but when running it on my local, the user admin from domain DOMAIN2 did not have the same privileges because my local machine was on a different domain say DOMAIN3 and did not by default give DOMAIN2\admin any rights on the system.
One way I circumvented the issue is by turning off impersonation like follows:
<identity impersonate="false" userName="DOMAIN2\admin" password="12345"/>
I suppose this defaulted my settings to use the rights from the currently logged in user.

ASP.NET Azure project does not appear to load newest content items

I have an ASP.NET MVC project and I am testing deployment to Windows Azure via the local emulator. I can run the project file fine in the development server but when I build the Azure project and it launches via the emulator I am having an issue with content files not being returned correctly. My internal CSS and JS files are being re-directed to the login page as if the authorization is failing; however I do not see where this auth requirement would be coming from.
Things I have already tried:
I have manually removed all the build files from both project (I have also tried the "clean" action for the solution)
I have tried removing the Azure project all together and creating a new one from the current version of my project.
I have tried clearing the local storage through the Azure storage interface.
I have verified that all my content is marked as "Content" in my ASP.NET project.
I have tried flagging all of my content items as "Copy always"
I have verified that the Static Content optional feature is checked
EDIT: I did a deploy to the web and everything works great there ... this is an emulator issue it appears. Any suggestions with that new bit of info?
You should verify your web.config just to be sure. Do you see something like this?
<system.web>
<authorization>
<deny users="?" />
</authorization>
...
</system.web>
Did you put the [Authorize] attribute on some of your controllers, or your controller base?
If it works in the cloud and in ASP.NET Development Server, I am not very sure why it doesn’t work in emulator. However I don’t think the issue is related to your application. For now, I would like to suggest you to check your IIS settings, such as applicationHost.config. Please see if there’re any authorization settings that may cause this issue(Compute Emulator uses IIS under the hook to host web roles). Please also try to host the site in a local IIS directly and see if the same issue could be encountered. If you can reproduce this issue in IIS as well, I would recommend you to consider to add a “IIS” tag to this thread, so more IIS experts will provide further suggestions.
Best Regards,
Ming Xu.
This thread has been open for a long time so I wanted to close it with what ended up being the solution.
It ended up being a bug with the emulator and the environment being used. As I mentioned, I was able to get it working when deployed. I actually tried this same situation 6 months later after updating to the latest Azure tool set and it worked fine so I am chalking this up to a bug in the emulator that has since been resolved.

Using SVNBridge with TFS (not CodePlex)

I'm trying to access my TFS Server using SVNBridge so I can work disconnected. I tried using the server-based as well as client-based solution. I'm just getting internal server 500 errors returned. I'm not sure I'm connecting to the site correctly though.
Other posts I've read concerning SVNBridge seem to exclusively be about CodePlex and connecting to it through a CodePlex specific URL.
I'm trying to connect to my own TFS server and wondering how to properly format the URL. Do I need to do something special for that? I feel like I've tried everything. Anybody have any success doing such a thing?
So apprently the problem is related to TFS 2010 Beta 2. The issue is being tracked here:
http://svnbridge.codeplex.com/Thread/View.aspx?ThreadId=77164
Thanks.
Not sure if you are still looking for an answer but I just spent the better part of my weekend getting it to work, mostly through trial and error so here is what I learned.
You CANNOT download the zip files and get anything to work if you are using TFS-2010. Instead you MUST download the source code and compile the thing for yourself.
You have to do the build on a computer with IIS installed to use the website project as is. This is what I did rather than change the project to use the development web server.
If you don't have VS-2008 installed anymore you can just upgrade the whole solution to VS-2010 and everything will be fine. I even changed the target of the website project to the 4.0 Framework with minimal issues. I had to unload the TestsRequiredTfsClient project and the Tools.HttpSend project to get the rest of the projects to build.
After you have built the project you need to follow a couple of steps that are outlined on the SvnBidge home page in order to get the bits into the right location on the web server. Once that is complete then you need to tune up the web.config file.
Here are the appSettings that you need to change and the values you need to use:
<add key="LogPath" value="--directoryYouWantToKeepLogsIn--" />
<add key="DomainIncludesProjectName" value="False" />
<add key="TfsUrl" value="http://--tfsServerName--:8080/tfs/--projectCollection--" />
<add key="ReadAllUserDomain" value="--yourDomain--" />
<add key="ReadAllUserName" value="--domainUserName--" />
<add key="ReadAllUserPassword" value="--domainUserNamePassword--" />
If you decided to upgrade the website to the 4.0 Framework don't forget that you need to update the application pool to because it was probably created as 2.0.
After you are almost done now that the website is set up. You still need to install some performance counters from the SvnBridge.PerfCounter.Installer project. After complication just copy those bits over to the same server you just installed the website on and run the exe.
THIS DIDN'T WORK
Okay so last but not least is security. I don't use the Digest security because all of my users have a windows login so I left anonymous access enabled and then disabled all other forms of access except Windows Authentication.
Windows Authentication didn't work for all of the users, some of them were remote. After looking at the source code it became clear that Basic Authentication was the only choice that was going to work. I needed the users to log in as them selves and then have that username passed into TFS so that as the check-ins are done they can be recorded to the correct user.
RP

Resources