allowDefinition='MachineToApplication' error only on my hosted website - asp.net

Error:
Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error can be caused by a virtual directory not being configured as an
application in IIS.
Line 10: </connectionStrings>
Line 11: <system.web>
Line 12: <roleManager enabled="true" />
Line 13: <membership>
Line 14: <providers>
Source File:
\Ns2\f\Users\cPanel\jdlferre\public_html\orangefresh\web.config
Line: 12
I've looked around the internet with no luck, I don't have any other web.config files on my subfolders, or even anywhere on my website. I don't use IIS so I've scratched that out too...
My website runs fine locally, it's only online that I get this error...

I would presume that your host is running your site within a sub folder of a website. The website will have a top level web.config in it, various sections of your web.config will then conflict with the parent configuration file.
I would suggest you try replicating that environment locally.

Ok, that now gives me a "Parser Error Message: Unrecognized attribute
'targetFramework'. Note that attribute names are case-sensitive." This
is also what happened when I tried moving my web.config file around. –
Joao Ferreira 1 min ago
That sounds to me like you're trying to run a .Net 4 or above website under a hosting provider that only supports .net 3.5
You can check by right clicking on the website root in Visual Studio, then going to "property pages" then click "build" (note: that's in VS2010, I don't have 2012, but it's probably quite similar). That should give you target framework information.
If you're using VS2012, then it probably creates a .Net 4 website by default, so it'll probably say .NET Framework 4.
If you're not using any controls that need .Net 4 or above, you can rebuild it in 3.5 and see if that solves the problem.
Otherwise, check with your hosting company to make sure they do host .Net 4 sites. Not all of them do, I've come across that exact problem a couple of months ago.

Related

IIS/ASP.NET not finding my Web App binaries

IIS 10.0 under Windows 10 Pro. ASP.NET 4.7
Please consider this a newbie question -- it's been a while since I've worked with IIS.
I'm researching some issues that only seem to occur running under IIS (versus running the website in Visual Studio 2017). So, I installed IIS 10.0 on my Windows development computer and published my website to IIS. The error described below is NOT the one I'm researching, but a roadblock in trying to get my website setup on my local IIS.
When I try to access the "home" page, I get a Parser Error.
Description: An error occurred during the parsing of a resource
required to service this request. Please review the following specific
parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'WingtipToys.Global'.
Source Error:
Line 1: <%# Application Codebehind="Global.asax.cs"
Inherits="WingtipToys.Global" Language="C#" %>
Source File: /global.asax Line: 1
(I also tried running Microsoft's Wingtip Toys sample website and I'm getting the same error as with my website. Showing Wingtip Toys error above.)
There is a BIN folder in my application (as installed in IIS), there is a WingtipToys.dll in that folder, and (according to .NET Reflector) there is a WingtipToys.Global class in the DLL.
I had thought ASP.NET would look for the BIN folder and use any DLLs it finds there.
As both the Wingtip Toys and my websites show the same error under IIS and both run fine in VS 2017, I suspect this may be an IIS or ASP.NET configuration error on my part.
What do I need to do to allow IIS/ASP.NET to find the binaries in my BIN folder? One suggestion I found was to put the following in my website web.config:
<system.web>
<compilation targetFramework="4.5">
<assemblies>
<add assembly="*" />
</assemblies>
</compilation>
</system.web>
While that works, we apparently don't need it on our production website (the one I'm trying to troubleshoot). (Plus, our production web.config has about 40 assemblies which are ALL in the website BIN folder. That seems to me redundant.)
I must be missing something.
If you have any questions, please let me know. Thanks!
As I figured, there was something missing from my IIS configuration. My original web app and the other sample web apps I used to test this were compiled as "Any CPU". In IIS, each of the application pools I used for these apps had "Enable 32-bit Applications" (under Advanced Settings) set to False. Once I set each one to True, all of the web apps worked as expected.
I no longer needed the "add assembly=*" workaround -- it looked like ASP.NET was finding what it needed in the BIN folder again. There was also an additional error of ASP.NET not finding the build provider for ASPX files. This additional error also disappeared.
Hope this helps someone in the future. Thanks for the replies!

Why does my ASP.NET Project/Website refuse to run when certain files are open in the IDE?

I ran my website earlier, and all was fine.
Then, after inspecting it with Resharper (and noting some issues it found, but doing nothing about them - changing no code at all), ran the site again - or tried to - and got:
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please
review the specific error details below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond
application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Source Error:
Line 56: </controls>
Line 57: </pages>
Line 58: <authentication mode="Windows"/>
Line 59: <sessionState timeout="360"/>
Line 60: <httpHandlers>
Source File: C:\MembersOrderEntryRedux\MembersOrderEntry\MembersOrderEntry\mobile\web.config Line: 58
Show Additional Configuration Errors:
Version Information: Microsoft .NET Framework Version:2.0.50727.5485; ASP.NET Version:2.0.50727.5491
Why would this be a problem now, when it wasn't before?
NOTE: I did notice that yesterday, this legacy project had a PROJECT menu in Visual Studio 2013, which today is no longer PROJECT but WEBSITE Why would that change, from one day to the next?
But, again, it ran fine the first time.
I then simply closed the files I had opened because Resharper had found "errors" in them (ASP, Javascript, and VB Compiler), F5'd again, and voila! - it runs fine again, as before.
Why does it care which files are open in the IDE?
BTW, I said "errors" re: what Resharper found because these don't prevent building or running (as long as the files it finds problems in are not open in the IDE).
The fragility of this is really giving me the fantods. It's hard to have faith my project will run from one time to the next, when it is so temperamental.
What set of actions need I avoid to prevent these will-of-the-wisp obstructions?

Configuration Error: <compilation debug="true" targetFramework="4.0"> ASP.NET MVC3

I'm trying to deploy my website on somee.com but keeps getting this error
I've tried googling and it says I have to change my App Pool to ASP.NET 4.0. I've tried that already but with no luck:(
Informations:
-My site was coded in 4.0 Framework
-I'm using .NET Framework v4.0 Integrated
-I have checked needed things already in Windows Features
-Im using ASP.NET MVC3
-I already typed cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319 then aspnet_regiis -ir to cmd
-64 bit OS
This is the steps how I publish my site
First I manually added this things to my Reference then changed the Copy Local to True
Microsoft.Web.Infrastructure
System.Web.Helpers
System.Web.Mvc
System.Web.Razor
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
I Editted this on my Web Config
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="None"/>
</system.web>
</configuration>
I add Deployable Dependencies that created _bin_deployableAssemblies which have this inside
Microsoft.Web.Infrastructure.dll
System.Web.Helpers.dll
System.Web.Mvc.dll
System.Web.Razor.dll
System.Web.WebPages.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.Razor.dll
I then click Publish and have this settings
This is how I Publish is this ok or I have to change something here?
I went to my IIS Manager. I right click on Default Web site Under Sites and choose Add Application with this settings
This resulted to this
I went to C:/inetpub/wwwroot and sees this files
I then compressed it as zip then uploaded it in my account in somee.com then checked my site and now I'm getting the Configuration Error above.
ABOVE IS MY UPDATED QUESTION I REPUBLISHED MY SITE AND INCLUDED STEPS HOW I PUBLISHED IT . I INCLUDED IT SO THAT YOU GUYS COULD SUGGEST IF I'M DOING SOMETHING WRONG ON HOW I'M PUBLISHING MY SITE AND COULD BE THE REASON OF THE ERROR ABOVE. THANKS IN ADVANCE :)
My site works fine in the iis of the localhost of my machine it only gets that error when deployed on the internet.
Btw I'm following the tutorials from these sites How to Deploy an ASP.NET MVC 3 App to Web Hosting with "\bin Deployment" Programming ASP.NET MVC 4 Chapter 19. Deployment Deployment ASP.NET MVC 3 project to IIS and somee
Question: What could be the cause of this issue :( It's my first time to deploy a website on the internet. Hopefully you could help me guys.. If you need more info please tell me.
My IIS Manager
My configuration
or could this be the reason of my issue?
OK THIS PROBLEM WAS SOLVED. I FOUND OUT THERE'S NO PROBLEM ON MY SETTINGS. THE PROBLEM IS ON THE SETTINGS OF THE WEBHOSTING SITE. I CHANGED THE ASP.NET VERSION FROM 2.0 TO 4.0 BUT FORGOT TO CLICK THE UPDATE BUTTON :( I FEEL BAD I HAVEN'T REALIZED THAT. I'M NOW FACING ANOTHER ERROR BUT IT HAS NOTHING TO DO WITH THIS QUESTION. THANKS GUYS FOR TRYING TO HELP ME :)
This typically happens when you have an attribute of targetFramework="4.0" in the web.config but the App Pool is set to run ASP.NET 2.0. The targetFramework attribute is entirely unrecognized by ASP.NET 2.0 - so changing it to 2.0 won't have the desired effect.
Contact Support / Your Administrator and have the AppPool switched to 4.0.
You could also remove the attribute entirely, however if your site was coded with the 4.0 Framework, then I'm sure something else will cause an error as well.
Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive
I was now able to find reason behind the error guys. It's on the webhosting site settings not on my app pool or what so ever. I changed the asp.net version from 2.0 to 4.0 but I forgot to click the update button. I feel so embarrased. :( I've been struggling for days to fix this error and only to found out its on the webhosting site settings. GgrrRR.. As of now I'm facing new error but has nothing to do with this question. Anyway thanks guys for your efforts to help me. :)
Try this, instead of selecting your websete's Application Pool to DefaultAppPool, select ASP.NET v4.0
Select your website in IIS => Basic Settings => Application Pool => Select ASP.NET v4.0
and you will be good to go. Hope it helps :)
Also try aspnet_regiis -u then aspnet_regiis -i on below path
C:\Windows\Microsoft.NET\Framework\v4.0.30319
Now restart the IIS and check
Hope this will help !
You could be using the 32 bit version, so you should prob try at the command line from the Framework (not Framework64) folder.
IE Did you try it from
C:\Windows\Microsoft.NET\Framework\v4.0.30319 rather than the 64 version? If you ref 32 bit libs you can be forced to 32 bit version (some other reasons as well if I recall)
Is your site a child of another site in IIS?
For more details on this (since it applies to various types of apps running on .NET) see Scott's post at:
32-bit and 64-bit confusion around x86 and x64 and the .NET Framework and CLR
Make sure that you are building your web app as "Any CPU". Right click your web project --> Properties --> Build --> and look for the "Platform Target". Choose "Any CPU" or play around with it.
Hope this helps!
Each individual Web App under an IIS Web Site can use a different App Pool.
Verify the App Pool assigned to your app (not just the root site per your pictures) is .NET 4.0 compatible:
Expand Default Web Site
Right click on ProjectPALS, choose 'Manage Application' then 'Advanced...'
Observe the 'Application Pool' your app is running as under the site
Change to another App Pool if neccessary
How are you running the application? Are you just hitting the website or are you building and running from within Visual Studio? If you are building and running you may want to tell it to use the local IIS web server. This would make sure it is using the App Pool you have set up to run with v4.0/integrated.
I am guessing that it is using the Visual Studio Development Server when running. This server is probably trying to run with the 2.0 framework. This then causes your error to be thrown.
Edit: To note, I normally just build my website application and then I attach to process w3wp when I want to debug. I do not use the publishing tool. Of course this means my local working directory is within the web root.
Have you tried the aspnet_regiis tool to register .Net 4.0 for IIS? You can check more at msdn
My problem was solved that way:
Your username is probably restricted, You must grant full access to the user.
Right Click on Project and select Properties
Click on Tab Security
Click Edit button
Found Current User and Permission for User Allow Full Control
If your application is 32 bit, and you want to deploy in a 64 bit machine, You need to set 'Enable 32 Bit Applications' property to 'True' in the application pool - advanced settings.

Not able to configure IIS 7 for ASP.NET 3.5 app

I developed a small ASP.NET 3.5 app. with only few pages and no DB connectivity. I am trying to publish it, but my website gives error:
**Parser Error Message:** It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
**Source Error:**
Line 45:
Line 46: -->
Line 47: <authentication mode="None"/>
Line 48: <!--
Line 49: The <customErrors> section enables configuration
I am using Windows 7 with IIS 7. When I add a new website in IIS there are a few concerns here. Below are the images that show that something is wrong underhood:
While creating new application pool for an application built on .NET 3.5, I could not see the .NET Framework 3.5 in the list:
When I open the Add Website dialog, and click Test Settings, it gives this error:
Please let me know how to fix this issue. I also want to know whether I have to add a website or add a virtual directory?
from the error message you provided, you have to have a virtual directory defined for your app with the pysical path pointing to your ASP.NET app folder, and also have the virtual dir as an application ("Convert to application" in the context menu of the virtual dir node, i think).
you dont need to create an app pool , but its probably a good idea.
also the registration issue that the guys here explain is also a must.
You have to register .Net framework for IIS using aspnet_regiis -icommmand?

Default.aspx with IIS 6.0 and .Net 4?

We have deployed a .net 4 asp.net site on IIS 6.0.
Default.aspx is configured as one of the default document.
When we access the site using the following url
http://testsite
We expect it to render
http://testsite/Default.aspx
But instead we get 404 Not found error. We did not had this issue when it was deployed on .Net 2.0. Only thing that has changed on the server is that we use .NET 4 instead of .NET 2.0.
UPDATE: I tried the following link but it did not work.
Getting an ASP.NET 4 application to work on IIS6
The framework version on the server is .NET 4 RC. Will it help if we install the latest .NET 4 version on the server?
Update: The issue is resolved now. The problem was a Third party upload control that we were using which added its own HttpHandler in Web.Config. This HttpHandler started failing in the .NET 4.
With the new .NET 4 framework, comes some problems if you are running it on IIS 6 Windows Server. IIS 6 does not let you have more than one framework at the time running in the same instance like IIS7 that can create Application Pool targeting different framework.
When IIS 6 runs under ASP.NET 2.0 (3.0 and 3.5 are superset, not frameworks) you are going to hit this error if the application is 4.0
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
Source Error:
Line 11: </configSections>
Line 12: <system.web>
Line 13: <compilation debug="true" targetFramework="4.0">
Line 14: </compilation>
Line 15: <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/> </ system.web>
You have a few options;
Downgrade the .NET application to 3.5 that Visual Studio 2010 makes it really easy. Just go to the Website properties -> Application tab and there is a drop down with all the framework releases, select 3.5, you VS2010 will reload the project and modify the web.config, if you added web service reference, that you may have to delete them and re-add them under 3.5
To configure the IIS6 and web config to solve the issue.
I deal with the second part:
In IIS 6 console, you need to right click you project and click the property and check the ASP.Net tab whether Framework 4 is selected or not. If not select the framework 4.
But still you might face the same error because of the application pool; you might have same application pool for two different framework web application.
IIS 6 does not let you have more than one framework at the time running in the same instance (means single application pool can’t use for two different frameworks) like IIS7 that can create Application Pool targeting different framework.
To solve this issue you need to create application pool and assigned this application pool to you framework 4 web application.
To assign the application pool, in IIS console open the properties section of the web application, and click on the “Home directory” tab and selection application pool which you have created earlier from drop-down-list.
This two might now solve your problem completely sometime. You can get the error as
“404 Page is not found”.
Though you might now have any issue while in development time.
Basically page is not found issue is cause of other problem which is set hidden by is IIS6 . But you need to see the real cause. What you have do here is go to the IIS6 console open “web service extension node” which is right below the “default website” node. You will see the entire ASP.Net framework list over there, by default these frameworks might be prohibited so please select ASP.Net Framework 4 and click allow button.
Browse you website now, you get other error beside “404 Page is not found”. You might get the error as listed below:
The value for the 'compilerVersion' attribute in the provider options must be 'v4.0'
You’ll see following error when browsing the website
The value for the 'compilerVersion' attribute in the provider options must be 'v4.0' or later if you are compiling for version 4.0 or later of the .NET Framework. To compile this Web application for version 3.5 or earlier of the .NET Framework, remove the 'targetFramework' attribute from the element of the Web.config file.
To solve this issue, you need to modify your web config file as below:
Previously the CompilerVersion value is set as v3.5 but we already change our targetFranework to 4. Thus according to the error message above the 'compilerVersion' attribute in the provider options must be 'v4.0' or later if you are compiling for version 4.0 or later of the .NET Framework.
Hence your new setting will be as below:
<providerOption name="CompilerVersion" value="v3.5"/>
Hope this will solve your ASP.Net 4 migration and hosting issue at IIS6.
Here is a link to a more complete solution and explanation of this:
http://johan.driessen.se/archive/2010/04/13/getting-an-asp.net-4-application-to-work-on-iis6.aspx
Check the server logs, they will probably give you a better idea of what is going on.
You can find the path to the log file by right clicking the website in IIS and go to properties. Then goto the Web Site tab, under 'Enable logging' click properties and the logging properties window will show up which displays the path to the log file.
I think in 4.0 the default page setting is actually stored in the web.config. With the IIS 7.0 , IIS reads the web.config the determine what to do for the default page. I think IIS 6.0 is not reading the setting.

Resources