AJAX.NET not working - c#

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

Related

Web.config in Views subfolder ignored on developer machine, why?

I have an ASP.NET MVC application with a root web.config and a secondary Views/web.config added automatically by Visual Studio years ago when the application was created.
Now I have bumped ASP.NET MVC to a newer version (5.2.7), fixed various issues on my developer machine - and everything works for me.
Unfortunately, when pushed to our integration test server, everything fails as there are MVC version references, in the Views/web.config file, that are now invalid for the new MVC version.
I can fix the version issues and everything is 200 OK ... but, and here is my question, why doesn't the errors show up on my local developer machine?
It turns out I can introduce XML syntax errors and what not on my local machine - and nothing happens, everything is okay locally, as if the Views/web.config file is completely ignored by the webserver.
Both machines are running IIS on Windows with the same configuration ... well, except that something apparently is different.
Where should I look to figure out why the Views/web.config is ignored on my developer machine?
The Views/web.config looks like this (with the wrong version numbers included):
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="CBrain.F2.SelfService.Mvc.Html" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<compilation>
<assemblies>
<add assembly="System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
Turns out that IIS behaves a bit strange: once the webpage loads correctly first time, I can change the Views/web.config without IIS detecting the change. But then I modify the main web.config ... whereafter IIS detects my changes in Views/web.config. Guess I have to live with that.

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>

Trying to add "Free Text Box" to a web.config file

So, I added a FTB by using a Formview that connects the database to the webpage.
When I tried to run the page and use the FTB, I was greeted with the following message:
"FreeTextBox has not been correctly installed. To install FreeTextBox either:
(1) add a reference to FtbWebResource.axd in web.config:
<system.web>
<httpHandlers>
<add verb="GET"
path="FtbWebResource.axd"
type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox" />
</httpHandlers>
</system.web>
(2) Save the FreeTextBox image and javascript files to a location on your website and set up FreeTextBox as follows
<FTB:FreeTextBox id="FreeTextBox1" SupportFolder="ftbfileslocation" JavaScriptLocation="ExternalFile" ButtonImagesLocation="ExternalFile" ToolbarImagesLocation="ExternalFile" ButtonImagesLocation="ExternalFile" runat="server" />"
I have already gone to the FTB download site and acquired the DLL. I created a bin folder in Visual Studio 2013 Exp and added the DLL to the file.
My web config currently looks like this:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\PageContent.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<httpRuntime requestValidationMode="2.0"/>
<httpHandlers>
<add verb="GET"
path="FtbWebResource.axd"
type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox"/>
</httpHandlers>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.Linq, 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.Web.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
Does anyone have any idea what I am doing wrong?
If you are using IIS 7 and above you might want to register it in the handlers section of the System.webServer section.
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="FreeTextBox" path="FtbWebResource.axd" verb="GET" type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox" preCondition="integratedMode" />
</handlers>
</system.webServer>

Microsoft Report Viewer Version 11

I am creating Microsoft Report Viewer Version 11, Works well locally, but when upload to the server I find the below error.
Report Viewer Configuration Error
The Report Viewer Web Control HTTP Handler has not been registered in the application's web.config file. Add to the system.web/httpHandlers section of the web.config file, or add to the system.webServer/handlers section for Internet Information Services 7 or later.
this is my web.config`
<?xml version="1.0"?>
<system.web>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
validate="false" />
</httpHandlers>
<customErrors mode="Off"/>
<compilation targetFramework="4.0">
<assemblies>
<add assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</buildProviders>
</compilation>
<pages controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID"/>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0,
Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
</handlers>
</system.webServer>
</configuration>
Your configuration settings is incorrect. The "name" attribute is missing the handler section. Use this instead.
<add name="Microsoft.Reporting.WebForms" path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>

Visual Studio 2010 bug? Wrong namespace in designer files

My Visual Studio 2010 Professional has started to produce incorrect designer files when editing aspx or ascx files. Visual Studio decides to use the System.Web.UI.DataVisualization.Charting namespace for all controls in the aspx/ascx files.
Example:
<asp:DropDownList ID="test" runat="server" />
ends up being this in the designer file:
protected global::System.Web.UI.DataVisualization.Charting.DropDownList test;
Has anyone else experienced this?
It appears that Visual Studio is unable to pick the correct namespace based on the registered controls.
I have resolved this issue by moving the charting registration to the top of the list. This result in the designer files being generated correctly again. The namespace for asp:Chart controls is correct too.
So my controls section in the web.config has gone from this:
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>
to this:
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
I still think there's a bug in VS that caused this behaviour.

Categories