turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

vb.net issues #416

Closed razmazn151101 closed 2 years ago

razmazn151101 commented 2 years ago

Hi, i am having trouble to figure out conversion in vb.net in global.asax regading this code i18n.UrlLocalizer.OutgoingUrlFilters += delegate (string url, Uri currentRequestUrl) { Uri Uri; If (Uri.TryCreate(url, UriKind.Absolute, out uri) || Uri.TryCreate(currentRequestUrl, url, out uri)) { If (url.StartsWith("?", StringComparison.OrdinalIgnoreCase)) Then { Return False; } } Return True; };

Hope you could assist

turquoiseowl commented 2 years ago

Hi, What kind of trouble?

razmazn151101 commented 2 years ago

i have converted it to vb using addhandler in my global.asax, but i am getting 404 error as i run it . Below are the code Sub Application_Start(sender As Object, e As EventArgs) ' Fires when the application is started RouteConfig.RegisterRoutes(RouteTable.Routes) BundleConfig.RegisterBundles(BundleTable.Bundles) i18n.UrlLocalizer.QuickUrlExclusionFilter = New System.Text.RegularExpressions.Regex("(?:sitemap.xml|.css|.jpg|.png|.svg|.woff|.woff2|.eot|.js|.html|.json)$|(?:elmah|bundles)")

    i18n.LocalizedApplication.Current.PermanentRedirects = False
    i18n.UrlLocalizer.UrlLocalizationScheme = i18n.UrlLocalizationScheme.Scheme2

    i18n.UrlLocalizer.OutgoingUrlFilters = AddressOf addLanguange
    i18n.LocalizedApplication.Current.DefaultLanguage = "my"
    i18n.LocalizedApplication.Current.CookieName = "i18n_langtag"
End Sub
Function addLanguange(ByVal url As String, currentRequestUrl As Uri)
    Dim uri As Uri
    If Uri.TryCreate(url, UriKind.Absolute, uri) Or Uri.TryCreate(currentRequestUrl, url, uri) Then
        If (url.StartsWith("?", StringComparison.OrdinalIgnoreCase)) Then
            Return False
        End If
    End If
    Return True
End Function
turquoiseowl commented 2 years ago

Are you saying it works if you don't add any OutgoingUrlFilters delegate, but you get 404 when you add the delegate?

razmazn151101 commented 2 years ago

Ok already solve it thanks