IIS/ASP.NET not finding my Web App binaries - asp.net

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!

Related

Execute IIS .NET webforms website without precompiling the source code

I want to publish to IIS the source code of my website (visual studio 2017 web forms website in vb.net or c#) without pre-compiling the project, so I can modify the source code directly on the server with IIS.
I know this is possible, I have done it in the past, and I have seen it done even now, but I cannot figure out what I need to do for this.
When I copy all the website source code to the server with the IIS, the website does not run... any ideas? or where to look for an answer? Is it a matter of setup? of the type of project?
When I call the website I get the following error:
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: The CodeDom provider type
"Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be
located.
Source Error:
An application error occurred on the server. The current custom error
settings for this application prevent the details of the application
error from being viewed remotely (for security reasons). It could,
however, be viewed by browsers running on the local server machine.
Thanks!
#Gabe Thanks for the directions:
File - New Project, I see it under Visual Basic/Visual C# - Web - Previous Versions (ASP.NET Web Forms Site)
I tried it, and it works just fine! Basically if you create a project like you describe, you can just copy the source code in a server, without even installing visual studio there, and you can develop the site directly there.
This is ideal when you want to test things directly with external users, test things directly on the live or test servers, and of course you can make sure you have the source code of the project running, without having to keep both the source code and the compiled version.
There are a few drawbacks though:
1) you disrupt the website when you change things, and the application pool is restarted whenever there are changes, users in sessions are kicked out, etc...
2) there is a small delay while the site gets recompiled
3) there are cases where if while the code gets recompiled there are users online, there is asp.net corruption
Thanks for the replies!!
Regards
Manos

Access denied on publish via ftp but works fine on publish to local IIS (.NET Application)

Soo.. I'm trying to help a friend build up hes photo-gallery-site.. Everything works just fine until i was about to publish it..
So to start of.. The first issue when i'm trying to push it up (VIA FTP - To citynetwork (webhost), i got:
Parser Error Message: The 'targetFramework' attribute in the <compilation> element of the Web.config file is used only to target version 4.0 and later of the .NET Framework (for example, '<compilation targetFramework="4.0">'). The 'targetFramework' attribute currently references a version that is later than the installed version of the .NET Framework. Specify a valid target version of the .NET Framework, or install the required version of the .NET Framework.
I've solved that to just change:
<compilation debug="true" targetFramework="4.6"/>
To:
<compilation debug="true" targetFramework="4.0"/>
But then i get another wierd error that looks something like this:
System.ComponentModel.Win32Exception: Access is denied - Cannot execute a program. The command being executed was "\\webstorage\storage_content\00\102600\elliotelliot.com\public_html\bin\roslyn\csc.exe"
Please help mee. I'm soooooo confused, i mean.. It works just fine when im publishing it to my local iis server and run it from there, all the files is also pushed up (nothing missing), anyone else with this issue?
I've seen people talk about application pools and users (therefore the "Access is denied" state)
Thanks!
/R
Please Check Why csc.exe is pointing to some other location than the framework location.
This is very similar to an issue I faced. I fixed it by changing the .NET Target version to 4.5. I changed it through Visual Studio instead of directly editing the web.config file, I don't know if this would make a difference or not.
There's more information, and more things to try in this article.
Hopefully something there helps.

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.

allowDefinition='MachineToApplication' error only on my hosted website

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.

ASP.Net Web Application Deployment -

I'm trying to deploy/publish my ASP.NET WebForms application in VS 2010 but i'm having trouble doing so.
On the build settings "Items to deploy" section I choose:
"Only files needed to run this application" since I don't want others to access the .cs/designer.cs files and other code data.
Everything works flawlessly it seems, but when trying to load up the default page with my browser I get the following error:
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: The file '/MyWebApp/Default.aspx.cs' does not exist.
When I look in the deployed folder I obviously can't see the .cs file mentioned above, but from my understanding, I shouldn't see it anyways, since all code behind files are compiled into MyWebApp.dll which is located in deployed folder's bin folder.
Last thing worth mentioning is that I've added:
<validation validateIntegratedModeConfiguration="false" />
in my web.config to fix a different error I got earlier.
Not sure that this has to do with the previous error, but I thought it's worth mentioning.
What am I missing?
It sounds like it is still a web site and not a web application. Please see the following documentation for information on differences between a web site and web application:
Web Application Projects versus Web Site Projects
and this documentation for how to convert your web site to a web application:
Walkthrough: Converting a Web Site Project to a Web Application Project in Visual Studio

Resources