Showing posts with label config. Show all posts
Showing posts with label config. 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?

Saturday, March 24, 2012

ajax and profileservice

I upgraded my web server to asp ajax 1.0 and changed my web.config to work with ajax 1.0.

my profile provider no longer works, whenever i attempt to access it, the application attempts to connect to a sqlexpress 2005 server and tries to create it in the app_data, however my connectoin string is for a sql2000 server tha thas the asp membership tables created in it

the error given is

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

SQLExpress database file auto-creation error:

The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:

    If the applications App_Data directory does not already exist, the web server account must have read and write access to the applications directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.If the applications App_Data directory already exists, the web server account only requires read and write access to the applications App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the applications App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server accounts credentials are used when creating the new database.Sql Server Express must be installed on the machine.The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.

all was working before i updated to ajax 1.0 when the namespaces were microsoft.web

how do i fix this?

nevermind, it was defaulting to localsqlserver connection string which was set to a sqlexpress database