Showing posts with label file. Show all posts
Showing posts with label file. Show all posts

Wednesday, March 28, 2012

AJAX Beta 2 web.config

Is there any documentation describing the sections needed in the web.config file to implement asp.net ajax into a site? I have installed it and am using it happily but I want an explanation of each element that is in that web.config template and why it is required, what I dont know worries me!

Thanks!

This is an excellent question.

I am going to give an explaination off my head:

First off:DOCS.

<configSections>
<sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="Microsoft.Web.Configuration.ScriptingSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="webServices" type="Microsoft.Web.Configuration.ScriptingWebServicesSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="Microsoft.Web.Configuration.ScriptingJsonSerializationSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
<section name="profileService" type="Microsoft.Web.Configuration.ScriptingProfileServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
<section name="authenticationService" type="Microsoft.Web.Configuration.ScriptingAuthenticationServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>

^^ This just defines how the config sections are laid out in the following markup in the config file.

The important stuff we should concentrate about is the inner section webServices and the sections below that (the outer ones just defines the layout of the config kinda (dumb sections that does nothing but define themselves ))

--

jsonSerialization,profileService,authenticationService are all on the same level. These actually have usable elements you can configure.

You should read the docs on what the classes are (they are vague though) but web.config found in C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025

has an actual section + comments:

<microsoft.web>
<scripting>
<webServices>
<!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
<!--
<jsonSerialization maxJsonLength="500">
<converters>
<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
</converters>
</jsonSerialization>
-->
<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
<!--
<authenticationService enabled="true" requireSSL = "true|false"/>
--
<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
and modified in Atlas applications, you need to add each property name to the setProperties and
getProperties attributes. -->
<!--
<profileService enabled="true"
readAccessProperties="propertyname1,propertyname2"
writeAccessProperties="propertyname1,propertyname2" />
-->
</webServices>
</scripting>
</microsoft.web>

jsonSerialization section can have defined custom converters, if you have an object that you want to provice your own notation for, do it here.

I don't know too much about the other stuff, but it seems pretty straight forward...

--

Moving on:

<pages>
<controls>
<add tagPrefix="asp" namespace="Microsoft.Web.UI" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="asp" namespace="Microsoft.Web.UI.Controls" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
<tagMapping>
<add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CompareValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CustomValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RangeValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RegularExpressionValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
<add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RequiredFieldValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="Microsoft.Web.UI.Compatibility.ValidationSummary, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</tagMapping>
</pages>

^^ <controls> will map the prefix 'asp' to the AJAX controls (mainly updatepanel, scriptmanager, updateprogress etc) GLOBALLY across the whole site, so you don't have to provide it in the directive on each page ( This is VERY useful to use on your own controls, this is a true blessing!)

The <tagmapping> will replace the stock ASP.NET validator controls with the ASP.NET AJAX ones. This is to override the original stock validator controls to make them work properly.

--

<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler" validate="false"/>
</httpHandlers>

First one replaces all requests (post, get (etc?)) to asmx files to the ScriptHandlerFactory. This factory is undocumented, but I can tell that it switches between 2 handler factories (it wraps them on a condition)

First one of them is RestHandlerFactory (undocumented), this will get chosen if it is a rest (if pathinfo starts with "/js").

If not, it will choose the stockWebServiceHandlerFactory class.

ScriptResource,axd axd is AJAX' own handler for processing script resources. This seems to be well documented (compared to other ajax stuffStick out tongue).

--

<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-ISAPI-2.0"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler" />
</handlers>
</system.webServer>


^^ This is the section for IIS 7.0 (or any web server that reads this section. maybe cassini?).

This will remove WebServiceHandlerFactory-ISAPI-2.0 and inject the script handlers / modules.

Some is documented, some is not. But this is probably to make the script stuff work, to use regular English. Big Smile

This is only from the top of my head. Some are facts, some are just my assumptions!

Anyway, hope it helps, and if it really is an answer to you,mark it as answer, thanks!


hello.

the final section will only be used by IIS 7 (and i do think that the web.config that comes with ajax beta 2 is not complete).

btw,?EmilChristopherMelar is there any contest with cool prizes or something like that? why are you asking for your answer to be marked at the end ofyour posts?
Because then you can see that a thread is really answered, so people can see that it doesn't need any more attention, duh.
hello.

well, didn't really know that there are people on this forum trying to find threads that need attention...

It's not about that. It's about aknowledging the answer so I don't have to follow it up anymore.

It is common sense and usage of news / forums to give a response on a successful / unsuccessful answer.

And what's the point of answering if it's not read / acknowledged? What would the motivation for helping be if your answer is blatantly ignored?

Wednesday, March 21, 2012

Ajax and file downloading

Dear all,

First of all, sorry for my english. I'm french !

I have developped an ASP.Net 2.0 web application. It allows to get data from 2 databases and merge them into a "csv" file. When the user presses the button Process, the execution can take several minutes to accomplish. Because file's size could be large, I used the recommended method of Microsofthttp://support.microsoft.com/kb/812406/en-us.

Thus, I wanted to use a method giving informations to the end user about the current process. I found the Ajax libraries, ie the updateprogress control which appears to be powerful. I installed the 1.0 version and add the references to the project. Everything works fine for the different examples giving in the tutorials.

Hence, I applied these methods on the page and executed the project. I got error messages on the client side when the user clicks on the button Process. Is there someone who has an idea ?

This the error message :
Client side error message when a file is going to be downloaded

Thank you for your help.

Best regards

Antony

If you reviewe the text of the error message, I think you'll find one of the suggestions is correct.

David Anson:

If you reviewe the text of the error message, I think you'll find one of the suggestions is correct.

Indeed, you're right, because I do not use Response.Write or something else equivalent. Otherwise, I don't how to bypass or use something diffferent... Thus, could you help me ?

I'm beginner in ASP.Net.

Best regards,

Antony


Does anybody have an idea?

Best regards,

Antony


So you're using the first method described in the link you provided but not Response.Write? What are you using then because thats whats in the article?

I made a mistake in my answer, I'd write "I should not use "Response.Write" instead of "I do not".

I effectively use the method provided by microsoft for dowloading udge files. However, it gives me the error when I use with ajax controls as updateprogress.

Antony


Thanks to the utility Web Development Helper, which allows you to get information that are posted back and received from the server, I found that only some partial part of the page was sent to the client in html code. Thus, I did not do it but I think that if you send via the Response.Write, a link to the files recorded on the server, thus, it would work and allows you to download files with Ajax.

If someone has the time to try. When I'll get some, I'll try myself.

Antony