I have a web application (asp.net webforms) that uses telerik controls, such as telerik:ReportViewer and telerik:RadTimePicker.
The interesting part is, the telerik library extensively uses the same dll (e.g. System.Web.Extensions), causing IIS Manager to issue "Duplicate Reference" error. Trying to simply delete the duplicate references causes some parts of the website to stop working.
How can I make same references to a single DLL within Web.config, without having to add duplicates??
Look why:
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
IIS reports duplicate references for each section element above. Deleting them causes the time picker to not show when clicked.
The same references goes in other places:
<compilation debug="true">
<assemblies>
...
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
...
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
...
</compilation>
And also:
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
<modules>
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
When running using Visual Studio (Debugging), everything fine. But once deployed to IIS, IIS reports errors of duplicates!!
It seems your website has been updated from old .NET versions and has become a mess of sections that newer .NET versions do not need. VS does not really rung on IIS by default so it probably does not read the entire web.config, hence things working on dev.
So, what you can try is:
start a new blank WebForms application targetting .NET 4 or .NET 4.5 , depending on what you target and copy its web.config. What you need to make sure is that you can run MS AJAX properly, so a simple asp:UpdatePanel on the page should let you have a working page first. This includes making sure all webresource requests pass.
see what you need to add for Telerik's controls here: http://www.telerik.com/help/aspnet-ajax/web-config-settings-overview.html#mandatory-additions. It is just a few handlers, those sections that error out are used by the core MS AJAX functionality.
try adding bindingRedirect element for the old Web.Extensions assembly to the new one.
Related
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>
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.
I am using AJAX Asynchronous Triggers. I created a project in VS2010 and everything worked fine. When I uploaded the same code to my server AJAX functionality stopped working. I installed AJAX extension for .NET but still the issue persists. My web.config file follows
<configuration>
<system.webServer>
<httpRuntime maxRequestLength="32768" executionTimeout="3600"/>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
<compilation defaultLanguage="c#" debug="false">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<customErrors mode="Off" />
<pages enableEventValidation="false" enableViewState="false" enableViewStateMac="false">
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
</system.webServer>
</configuration>
When I add handlers/httpHandlers to my web.config file I am getting 500-Internal server error.
<handlers>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
</handlers>
you should first check framework installed on your web server.
according to your web config your application is in framework 1.0 but you added handler of framework 3.5.
Update
please updated you handler section and upload again and then check.
hi mad coder update your config with this code and check again
<configuration>
<compilation defaultLanguage="c#" debug="false">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
</configuration>
and add this handler to your web config
<handlers>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</handlers>
For .NET 2.0, ASP.NET AJAX 1.0 is used. Write correct assembly version to HttpHandlers in web.config. See the documentation: Configuring ASP.NET AJAX
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.
Let me preface this (Because I know I'll get this eventually in the responses)
Yes I know about WCF, but we are not using that or plan to right now (boss won't budge)
Ok, so my questions are the following. First I want to move some of our .asmx into a separate project. Right now it's in several scattered folders in our WAP project. Ok so if I create a new project:
1) What type should it be?
2) What deployment issues do I now have to face? Someone told me that if we move it to a separate project, we have to deploy it separately, I assume that means IIS, and yes, copying up that project to another place on the server
3) I was told that if we move it out of the WAP project we can no longer have that service run under our domain (something.com). But then someone told me you can setup a single web service to be a "pass-through" and have the actual .asmx files wherever you want? I don't get that.
The main concern is moving it. How to expose the services in that web project as we'll have multiple. How to deploy (both the files and IIS) it and then how to make sure it's still available under our same domain in production.
The asmx file is simply a pointer to the C# code file. You can include the asmx files anywhere in your web project.
You can create a Web Service project in Visual Studio IDE, or simply create a Class Library and add the necessary references.
A web service project uses the following DLLs:
System.EnterpriseServices
System.Web
System.Web.Extensions
System.Web.Mobile
System.Web.Services
And the following web.config reference:
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpHandlers>
Agreed, create a new Web Service Project.
There's no issue having your webservice be deployed alongside your existing site in IIS.
Create your existing site url www.something.com then within IIS add a virtual directory or application to myservice so that you get www.something.com/myservice/awesome.asmx.
You could also create yourself an alternate host header to direct webservices.something.com to your webservices.