Wednesday, March 28, 2012

Ajax trouble with Localization HttpModule

Hello,

I'm using this HttpModule :

Imports System.WebImports System.Web.SessionStatePublic Class URLLocalizationHttpModuleImplements IHttpModule, IReadOnlySessionStateDim LangueAs String Dim OriginalURLAs String Public Sub Dispose()Implements IHttpModule.DisposeEnd Sub Public Sub Init(ByVal contextAs HttpApplication)Implements IHttpModule.InitAddHandler context.BeginRequest,AddressOf context_BeginRequestAddHandler context.AcquireRequestState,AddressOf AcquireRequestStateEnd Sub Private Sub context_BeginRequest(ByVal senderAs Object,ByVal eAs EventArgs)Dim requestAs HttpRequest =CType(sender, HttpApplication).RequestDim contextAs HttpContext =CType(sender, HttpApplication).ContextDim applicationPathAs String = request.ApplicationPathIf applicationPath ="/"Then applicationPath =String.EmptyEnd If Dim requestPathAs String = request.Url.AbsolutePath.Substring(applicationPath.Length) OriginalURL = requestPath LoadCulture(requestPath) context.RewritePath(applicationPath + requestPath)End Sub Private Sub AcquireRequestState(ByVal senderAs Object,ByVal eAs EventArgs) HttpContext.Current.Session("OriginalURL") = OriginalURLEnd Sub Private Sub LoadCulture(ByRef pathAs String)Dim pathParts()As String = path.Trim("/"c).Split("/"c)If pathParts.Length > 0AndAlso pathParts(0).Length > 0Then Dim LangAs String = pathParts(0)Dim supportedLanguagesAs NameValueCollection = ResourceManager.GetSupportedLanguages()Dim supportedLanguageAs String = supportedLanguages(Lang)If Not (ResourceManager.IsNullorEmpty(supportedLanguage))Then path = path.Remove(0, pathParts(0).Length + 1)End If End If End SubEnd Class

When it is activated in web.config localization works fine but ajax not.

I get this error:

Sys is not defined

Can anybody help me ?

hello.

i think you can use fiddler to see what's happening but i'm almost positive that you're not getting the client files on the client. before rewriting the path you should check for scriptresource.axd requests and you shouldn't change the url for the those requests (they're responsible for getting the client js files onthe client side - btw, don't do it either to webresourece.axd requests)

No comments:

Post a Comment