'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' - c#

I want to access root url of a Web application from a Windows forms Application.
string rooturl = Billing_XML_WebTracking.WebForm1.RootUrl;
string url = rooturl + "/WebForm1.aspx";
webBrowser1.Navigate(url);
So I have added the below code to Web.config of the Web Application :
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
And the final code of Web.config file is
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</compilation>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
</configuration>
But while building the solution, it is giving below error
The type 'System.Web.UI.Page' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Please help me out.Thanks

In References you must add System.Web.dll

Related

AjaxControlToolkit AjaxFileUpload can't upload IIS Reserved File Types

I am writing/ have written a file upload portal for my company that requires the ability to upload a ton of different file types of various sizes and quantities. I used the AJaxControlToolkit AjaxFileUpload control.
The upload works well except when we upload what seems like IIS reserved file types. We can upload images, entire non-zipped folders, office docs etc.
When I try to upload the reserved file type the Firefox developer tools returns a server error, 'File Extension Not Allowed' error. This happens with .exe files and the one we need .stl files(in our case these are for 3d printing).
We have played with config files, Handler Mappings, HTTP response headers, MIME type configurations, and request filtering on the IIS manager at the app level, site level and server level and none seem to work.
The last bit of info is that zipping the file seems to get it through but we'd like to avoid asking the customer to do that.
IIS 8.5,
C# .Net,
Windows Server 2012 R2
I can post code if you need it but I am pretty sure it is a server configuration we need to change
Thanks for your help.
Walt
Edit:
Below is my Config with the Fix included. this was an issue with white listed file types by the control and not the server. Thank you
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="ajaxControlToolkit" type="AjaxControlToolkit.AjaxControlToolkitConfigSection, AjaxControlToolkit" requirePermission="false"/>
</configSections>
<appSettings/>
<ajaxControlToolkit additionalUploadFileExtensions="bmp,stl"></ajaxControlToolkit>
<system.webServer>
<handlers>
<add name="aa2" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
</handlers>
</system.webServer>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
<pages>
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"/>
</controls>
</pages>
</system.web>
</configuration>
You need to add the additionalUploadFileExtensions attribute to ajaxControlToolkit section in Web.config:
<ajaxControlToolkit additionalUploadFileExtensions="exe,stl" />
Please refer to this article: https://github.com/DevExpress/AjaxControlToolkit/wiki/AjaxFileUpload-setup
For an example of where to ajaxcontroltoolkit entry in the web.config file, please refer to Sample web.config Ajax configuration
Sample below:
<configuration>
<configSections>
<section name="ajaxControlToolkit" type="AjaxControlToolkit.AjaxControlToolkitConfigSection, AjaxControlToolkit" requirePermission="false"/>
</configSections>
<ajaxControlToolkit
useStaticResources="true"
renderStyleLinks="false"
htmlSanitizer="AjaxControlToolkit.HtmlEditor.Sanitizer.DefaultHtmlSanitizer, AjaxControlToolkit.HtmlEditor.Sanitizer"
tempFolder="~/Temp"/>
<location path="Temp">
<system.webServer>
<handlers>
<clear/>
</handlers>
<modules>
<clear/>
</modules>
</system.webServer>
</location>
<system.web>

upgrade to .NET 4.5

I recently had a C# web solution where I had to upgrade from .NET 3.5 to .NET 4.5 to upgrade TLS 1.2 security. I changed the build setting in the properties of each project of the solution which now builds just fine. I am also able to update the code behind just fine, but now I can't make any changes to the ascx.cs files for any user controls. If I do, there are build errors.
I looked up the solutions for the erro message I get: 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
but they all say to remove or update the compilation tag in the web config. I tried removing it and that didn't work and the tag shows 4.5 and lower 4.0 as expected. here are the tags in the web config
<compilation targetFramework="4.5">
<assemblies>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
<add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=[some token]"/>
</assemblies>
</compilation>
<pages controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID"/>
If it makes a difference, this is a set of modules for dotnetnuke (and the publish on Dnn7 works fine I just again can't make changes to the user controls, I need to do this to maintain the software)
If you're working in Visual Studio, and you have a web.config file IN the /desktopmodules/MODULENAME/ folder, remove that. You don't need it, it was placed there during the .NET Framework change.

Razor intellisense does not work in vs2013

The Razor intellisense stopped working in one MVC 4 project, and one project only on my pc. I use Visual Studio 2013 Professional. I know this is an issue that has happened to a lot of people before me. I've tried many possible solutions, but the one that works for me has not been there yet...
A list of what I tried so far:
Delete the temporary .suo file
In tools->options check Auto list members
Remove the project from the solution and add it back
Create a new Visual Studio MVC project and copy the web.config file
Delete old Visual Studio 2010 settings in AppData/Roaming/Windows/Visual Studio
Change MVC version in web.config file in Views folder
Clean the solution, exit VS, reopen it and rebuild entire solution
Unload and reload the project within the solution
and probably I tried more which I can't remember right now. Does anyone have another solution/tip to solve this?
Suggested answers for this post which didn't work either:
Repair Visual Studio and reinstall ASP .NET MVC
I've faced same kind of problem with different causes and solved as follow:
web.config in all views folders: I got a correct version of web.config creating a new Area in my project and using it in other view folders
Feature … cannot be used because it is not part of the ISO-2 C# language specification generally these kind of errors does not block compilation, but could be very annoying. To solve this error I've added this segment in web.config (or in app.config if your project is not a web project)
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<!-- ASP.NET 4.0 Assemblies -->
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
local assemblies: sometimes, when I've used external assemblies (for helpers e.g.) I've had to check for Copy Local = true in Project references.
In all cases It could be needed to close/reopen VS to get the modification applied.
hope it helps

LINQ not in namespace

I have a web project in visual studio 2012 that I am working with over an ftp connection. I am getting the error that the Linq does not exist in the namespace System.Data and Linq does not exist in the namespace System. Visual studio displays an error and will not give code suggestions, however, the code runs fine on the IIS server.
My web.config contents are below.
I have read over the many questions and articles on this problem and was still unable to find a working solution.
<system.web>
<compilation debug="true" strict="false" explicit="true" urlLinePragmas="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.Services.Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Data.Linq"/>
<add namespace="System.Linq"/>
<add namespace="System.Xml.Linq"/>
</namespaces>
</pages>
Try to manually add the reference to System.Data.Linq in your project.This should hopefully resolve your problem.
Project -> References -> Add reference -> System.Data.Linq
This comes a little late, but in the interest of "giving back"..... When I had this issue (VS 2010 running website through IIS), I had to change the target framework to something else, save the changes, and then change it back to v 4.0 (the original my project was built with). (Right-click Project -> property pages -> Build -> "Target Framework"). That cleared up the issue. Not sure how or why. =)
In Visual Studio, check that the project is targetted to a version of the .NET framework that includes Linq. Right click on the project, then look for the Target Framework option. If this is set to v2, everything else that VS tells you will be based on v2 - the available assemblies, the versions of the base class library assemblies, etc.
This happens to me when I upgrade from VisualStudio 2013 to 2015.
I encounter to these errors while the Project build doesnot comes to the end and stops after some warnings. I resolve these warnings, and when I solve the last warning:
Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=11.0.0.0, . . .
the error:
the Linq does not exist in the namespace System
get solved.

c# System.guid does not contain a definition for Parse

AT.Anchor = System.Guid.Parse(DataBinder.Eval(e.Item.DataItem, "Anchor").ToString());
This throws:
'System.Guid' does not contain a definition for 'Parse'
When I try and build it. But it runs fine, any idea how I can handle this better?
Edit
Here is a section of my web.config
<compilation defaultLanguage="c#" debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
<add assembly="MySql.Data.Entity, Version=6.3.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
<add assembly="MySql.Web, Version=6.3.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/></assemblies>
</compilation>
Guid.TryParse is part of .NET 4. Make sure you're both building and running against .NET 4, and it should be fine.
One of the things with IIS app pools is that the first web application that starts in an app pool determines the CLR version used by that app pool.
If the first app started was built for, say, .Net v1.1, then every app started after that will run against the v1.1 runtime. If your app, which gets started next, was built for, say, the 4.0 runtime, you're unlikely to find happiness. Some might consider this to be a feature. Or not.
"Start", in this case, means "receives an HTTP request". This means that the runtime version you get is essentially random: it depends on what the clients do, and in what order, after your bounce the app pool or bounce IIS.
You need to be careful to put your web apps in appropriate app pools. Either bundle each web app in its own app pool, or set up an app pool per CLR version and be careful to put your web apps in the correct app pool.

Categories