1

I have built one website using the .net framework 4.5 . Here is the code snippet from the Web.config file.

   <compilation debug="true" targetFramework="4.5"/>

I have hosted the same website in my local machine IIS7. While creating a new website, Application pool I selected as 4.0. When I try to access the same from the browser I am getting below error.

   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: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.

   Source Error: 
   Line 14:   -->
   Line 15:   <system.web>
   Line 16:     <compilation targetFramework="4.5"/>
   Line 17:     <httpRuntime/>
   Line 18:     <pages controlRenderingCompatibilityVersion="4.0">

   Source File: C:\inetpub\wwwroot\polygontechnologies.com\web.config    Line: 16 

   Version Information: Microsoft .NET Framework Version:2.0.50727.5485; ASP.NET Version:2.0.50727.5491

So, as of now I have targetFramework="4.5" in web.config and in IIS application pool it is 4.0.

Can anyone help me in fixing the issue. TIA

Pacchi
  • 57
  • 1
  • 7
  • this is probably more of a web applications stack exchange question eh? http://webapps.stackexchange.com/ – Brett Caswell Nov 21 '15 at 01:05
  • See http://stackoverflow.com/questions/7530725/unrecognized-attribute-targetframework-note-that-attribute-names-are-case-sen – toddmo Nov 21 '15 at 01:08
  • Thanks for your reply. I have seen the post that you have shared. But in their case - In Application pool, target framework - 2.0 and Website built using framework 4.0. But in my case - In Application pool, target framework - 4.0 and the application was built using framework 4.5 . – Pacchi Nov 21 '15 at 01:12
  • do you have it installed as a 'Feature'? is this your first time Hosting on IIS 7 on this workstation/server? – Brett Caswell Nov 21 '15 at 01:16
  • "Control Panel\All Control Panel Items\Programs and Features" > "turn Windows Features on and off" > "World Wide Web Services" > "Application Development Features" tell us what is checked on and off.. – Brett Caswell Nov 21 '15 at 01:19
  • Thanks for your reply. Yes it is the first time I am hosting on IIS7 in my local machine. One more thing I found. When I tried to browse Application which is hosted on IIS, I am getting below error "The server at xx.com can't be found, because the DNS lookup failed. DNS is the network service that translates a website's name to its Internet address. This error is most often caused by having no connection to the Internet or a misconfigured network. It can also be caused by an unresponsive DNS server or a firewall preventing Google Chrome from accessing the network." – Pacchi Nov 21 '15 at 01:20
  • typically, one just does localhost in their browser at first – Brett Caswell Nov 21 '15 at 01:22
  • .Net Extendibility, ASP.net, ISAPI Extensions and ISAPI Filters are enabled in Windows Features on and off – Pacchi Nov 21 '15 at 01:22
  • turn on ASP.NET 3.5 and 4.5/4.6 – Brett Caswell Nov 21 '15 at 01:23
  • in Common HTTP Features, turn on Default Document and Static Content as well.. – Brett Caswell Nov 21 '15 at 01:24
  • Yes they are on. Is there any connection between turning on of ASP .net 3.5 and 4.5/4.6? As I can see in my Programs and Features, only 4.5 and 4.6 frameworks are installed. 3.5 is not installed – Pacchi Nov 21 '15 at 01:30
  • my mistake @Pacchi I was referencing IIS 8.. ASP.NET 3.5 and ASP.NET 4.6 are explicitly defined there.. I suppose IIS 7 only specifies ASP.NET – Brett Caswell Nov 21 '15 at 01:32
  • Brett, What may be the issue in browsing the website directly from IIS and getting DNS error? – Pacchi Nov 21 '15 at 01:35
  • if you had an error going to 'localhost' it could be a hook in your host file `%System32%\driver\etc\host` – Brett Caswell Nov 21 '15 at 01:36
  • Brett, here is the content of host file. But I dont find any suspicious about it. # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost – Pacchi Nov 21 '15 at 01:39
  • lets go to http://chat.stackoverflow.com/rooms/7/c until we can sort through this.. – Brett Caswell Nov 21 '15 at 01:42
  • sorry. don't have 20 reputation points to continue with chat :( – Pacchi Nov 21 '15 at 01:43
  • Brett, thanks for the support. after trying for long time, i uninstalled and installed iis. Hosted the application once again fresh and it is working fine. I am not sure what was the issue :) – Pacchi Nov 21 '15 at 13:25

1 Answers1

1

Try changing your app pool to use framework 4.0

and if that doesn't work, try aspnet_regiis -i

toddmo
  • 20,682
  • 14
  • 97
  • 107
  • Thanks for your reply. As I mentioned earlier, App pool is using framework 4.0 and Website built using framework 4.5 . But still I am getting the error – Pacchi Nov 21 '15 at 01:16
  • as I mentioned in my comment section of question asked, while browsing from IIS I am getting DNS error. But getting target framework error if I am trying to access the localhost from the browser directly – Pacchi Nov 21 '15 at 01:32
  • toddmo, yes it is in integrated mode. Testing in local host and getting DNS error. – Pacchi Nov 21 '15 at 01:38
  • @Pacchi, as an experiment, try removing the `targetFramework` attribute. Also, ensure 4.5 is installed. – toddmo Nov 21 '15 at 01:59
  • toddmo, I did comment the targetFramework attribute from web.config and try to debug the code. Getting following error "CS1617: Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default" – Pacchi Nov 21 '15 at 02:04
  • @Pacchi, this error occors because the project was created with VS 2015 but you are using 2013 or lower. Go into proj file with notepad and remove that langversion if you want to open with < 2015. 2015 comes with C# version 6. Or open it with VS 2015 (better option). If you edit with Notepad, make a backup first. – toddmo Nov 21 '15 at 02:06
  • toddmo, yes the project is created with VS 2015 and I am using the same. I dont have any other version of VS in my machine. – Pacchi Nov 21 '15 at 02:08
  • ok go into project properties and remove that language version, and now you can do experiments trying to compile / run web site by changing the target framework version property in the project itself to 4.0. Maybe that will tell you something if that works. Make sure it compiles just by saying "Build" or "ReBuild". – toddmo Nov 21 '15 at 02:09
  • ok thanks toddmo, i will try it tomorrow and update you as its 5 AM now. Have to catch up some work in the morning. – Pacchi Nov 21 '15 at 02:12
  • toddmo, I tried changing language version, rebuild the website and run it by changing the target framework version as suggested. Still same issue :( – Pacchi Nov 21 '15 at 09:12
  • Does it run in iis express in the debugger? – toddmo Nov 21 '15 at 09:14
  • toddmo, thanks for your support... after trying for long time, i uninstalled and installed iis. Hosted the application once again fresh and it is working fine. I am not sure what was the issue :) – Pacchi Nov 21 '15 at 13:24