ASP.NET TargetFramework attribute isn't recognized - asp.net

I have been trying to make a project, but in web.config, it keeps giving me the error that it doesn't recognize the attribute TargetFramework.
EDIT: Added the web.config. I have seen one question with the same problem and they said there that it should be the same version as the version of ASP.NET. But i don't really see how to do that.
P.S. i can't change to a different version of Visual Studio (i use that program) since it won't allow me to run the files on local web. But that's a different problem.
Been a while now. Guess it's a tough problem.
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true" targetFramework="4.0">
<assemblies>
</assemblies>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/> </system.web>
<system.codedom>
</system.codedom>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
</system.webServer>
</configuration>

This happens basically 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 -This means it will not work even if you changed it to 2.0 in config file.
If your application is coded in 4.0 then the AppPool is need to be set up to 4.0
In IIS > Right click on WebSite > Properties > ASP.NET > Version > "Should read 4.0.21006" not 2.0

I've gotten this error when trying to use Fortify with Visual Studio. The Visual Studio Fortify plugin seems to want to use the aspnet_compiler instead of msbuild. It was throwing that exact message.
When I used the command line tools to have Fortify compile using msbuild, it worked. Perhaps your Visual Studio is not using msbuild? You may want to try converting it to a web application if it's not already. I think then Visual Studio will use MSBuild by default. Not sure if this is your problem, but I did get that exact same error message. Good luck.

Related

Error Webforms UnobtrusiveValidationMode when application is published on iis

My web form application works fine when it's run in Visual Studio 2013. I published the same application on iis version 6.1.
It's giving the following error.
Webforms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).
I already have check with multiple solutions given on stackoverflow. most of them suggested to add following line in appsetting in web.config file.
<add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" />
or change the following from 4.5 to 4.0. but it's futile.
<httpRuntime targetFramework="4.5"/>
Even this could not helped me to find a solution. What is causing this error? and how can this me resolved?
You have to add following configuration in your Web.config file which is going to enable pre-4.5 validation mode. Since None is not its default value if you are using targetFramework="4.5" you have to explicitly add this to your configuration.
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>

Configuration Error related to targetFramework in web.config

I have made an MVC website in Visual Studio 2015 and it works in my localhost. But when I published my website and put into my host, it doesn't work. It gives me this error notice:
Server Error in '/' Application.
Configuration Error
Parser Error Message: The 'targetFramework' attribute in the
element of the Web.config file is used only to target
version 4.0 and later of the .NET Framework (for example,
''). 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.
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.
Source File: G:\xxx\xxx.com\httpdocs\web.config Line: 24
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.34248
Related parts in my web.config:
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
And this part with error:
<system.web>
<authentication mode="None" />
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.6" />
<httpRuntime targetFramework="4.6" />
</system.web>
Properties of my website:
And NuGet Package Manager:
EntityFramework Reference Properties:
Default Web Site Basic Settings: (To be honest, I am not sure whether I should add a new website(my website) in here.)
My installed .net frameworks:
My publish method:
I have investigated this problem on the Internet and I have found several links related to my problem: Asp.net MCV4 framework issue. In this link, there are two main offers:
changing this compilation tag
updating application pool in IIS
Actually, I have tried to change this tag but it doesn't change. Then I have controlled my application pool but it seems up-to-date.
I have called my host provider and I have explained my problem. They say that this error is not related to their servers.
What should I do? What is the solution for this?
Your website project is targeting v4.6 of the .NET Framework but your hosting provider has not yet installed this version. Your options:
Ask provider to install it - they are unlikely to do this.
Find another provider that does support it.
Change your project to target v4.5.
I'm adding one more information to complement DavidG's answer. If Internet Information Server (IIS) is your provider then Web Platform Installer (an IIS extension) is a very helpful tool. It can your best bet to check the current state of what all components are installed on your machine (Refer screenshot)
It is very easy to check what all components are missing from your computer. Based on that, you can kick-start installation of any missing component through the UI of this IIS extension itself.
I just had a similar problem following the installation ( windows update) of the KB 3205402.
Big difference with my case: the application worked well before the update !
==> I found in "IIS Manager", in "ISAPI and CGI Restrictions", that the framework ASP.NET v4.0.30319 has been switched to "unauthorized" !
Switching it to "Authorized" resolved my problem
I changed:
<system.web>
<compilation debug="true" targetFramework="4.7" />
<httpRuntime targetFramework="4.7" />
<customErrors mode="Off"/>
</system.web>
to
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<customErrors mode="Off"/>
</system.web>
i.e, changed targetFramework value to 4.5 (the one supported on server) from 4.7. and worked.
had the same issue on the below line on an offline server ,
<compilation targetFramework="4.5.2">
tried adding all the roles and features related to .Net framework from the server manager and to its pool ,
but didn't work , what worked for me is just downloading Microsoft .NET Framework 4.5.2(Offline Installer)
I went round and round with this today with no resolution. Exasperated, I finally just deleted my working copy from my drive, and rechecked it out from SVN.
Fixed.
Not a particularly clever answer, but it fixed it for me, no idea what the actual problem was.
I tried replacing the targetFramework 4.5.2 to targetFramework 4.0 directly in config file. Then it and all the functions work correctly.
Before:
<compilation targetFramework="4.5.2">
After:
<compilation targetFramework="4.0">

.NET Web API 2 Project downloading browserLink.js

I've got a .NET Web API project and on load I'm getting a download of this script called browserLink.
http://localhost:49818/ea93983f23c54f35a63de09646c09159/browserLink
Its associated with .NET Signalr but I'm not using that so I'm not sure why its being included. Any ideas how to turn it off?
Disable Browser Link in Visual Studio 2013.
Do this by editing your web.config file to add the following line to your appSettings section:
<appSettings>
<add key="vs:EnableBrowserLink" value="false"/>
</appSettings>
Note that Browser Link is only used when working in Visual Studio AND the web application is compiled in debug mode, i.e.:
<system.web>
<compilation debug="true" />
</system.web>
In other words, end-users of your site will never make this request.

Is it possible to host an aspx (.NET 4.0) website locally on Windows 8 Enterprise?

As the title states is it possibly to host a dynamic (that would be .aspx correct?) website locally (IIS 8) on a computer running Windows 8 Enterprise? I've installed all the IIS components, added the website as many guides on Google will show but I get error 9 as stated here:http://support.microsoft.com/kb/942055
my web.config is as follows:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.0"/>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I also have the correct version set for the site (.NET 4.0) and tried resetting all feature delegations. At this point I'm thinking of just doing a cheese puff solution and just running the site via the built in server within Visual Web Developer.
"Stock" ASP.NET Web.Config file
When I create a standard, empty ASP.Net Web Forms Application targeting .NET Framework 4.0, here's the standard Web.config file that's generated:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections />
<connectionStrings />
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/" />
</authentication>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
EDIT: I removed the Membership, Role, Profile, and SessionState sections that were previously here. These aren't, strictly, required but are part of the standard Empty ASP.Net Web Forms Application template to help you get started quickly. What is shown above is the minimum Web.config you need.
NOTE: Don't worry about the debug="true" in the <Compilation /> element. You should have that attribute set to false in production anyway.
I Suspect it's your IIS Configuration
After re-reading your question, I suspect that you haven't properly configured IIS to host the site properly.
First, I want to start by saying that there's Internet Information Services (IIS), the actual web server, that can be installed on Windows 8 as well as server OSes such as Windows Server 2012. There is also IIS Express, used for development and which is a replacement for the old Development Web Server (code-named Cassini) in VS2008 and VS2010 (prior to SP1 when IIS Express was made available through an additional installation).
It sounds to me like you have installed IIS under Windows 8 Program and Features. Now you need to create a site in IIS that points to where your web application is located on your hard disk.
Open IIS Manager
Expand your machine name in the Connections pane on the left.
Expand the Sites folder. There should already be a site called Default Web Site.
Right-click the Sites folder and choose Add Website....
Give the site a name. Choose the DefaultAppPool for now (you can change it later).
Under Physical path, browse to where your web site/application is located on your hard disk.
Click OK.
There are other options on that page and you can find help on them at MSDN. That may be enough to get you started, though.

Production issues - disable ASP.NET debugging, restrict access to directory

I deployed my latest web site to production environment, now client found that the following issues on my deployment. and that are to be fixed.
I just need some clarification from you all on the following
disable ASP.NET debugging
I already set compilation debug="false" in the web.config, is there anything that to be done apart from this?
restrict access to directory
any idea on defining access rights for users?
Have you tried this:
<compilation
debug="false"
/>
on your web.config
HOW TO: Disable Debugging for ASP.NET Applications
ScottGu's Blog
this will display the exact error that user gets.
And if your application has an download.upload file into a folder you need to
Share Folder name “YourFileFolder” and add ‘Network Service’ account having read/write permission
Regards
There is a configuration setting in machine.config(only) called:
<configuration>
<system.web>
<deployment retail="true"/>
</system.web>
</configuration>
This parameter will automatically turn off debugging features(tracing,compilation,...).
For your security rights, give only access on your directory to the iis pool user.
To disable Browsing in IIS7 add this to your web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="false" />
</system.webServer>
In my case (error:
debugging should be disabled in the web.config file
) i basically turned web.config to :
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
note:I use Visual Studio 2010

Resources