locked
global asax unicode problem RRS feed

  • Question

  • User1456523893 posted

    hello,

    i have a querystring and it holds a unicode string but it gives me this output (کوردستان)

    from this url ( Context.RewritePath("/Hewalekan.aspx?type=1&Title=کوردستان"))

    regards.

    Wednesday, October 17, 2018 9:15 AM

Answers

  • User-369506445 posted

    please try below

     Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
            
    
            Dim varRawUrl As String = HttpContext.Current.Request.RawUrl
    
    
            If varRawUrl.StartsWith("/About") Then
                Context.RewritePath("About.aspx")
            ElseIf varRawUrl.StartsWith("/News/Kurdistan") Then
                Dim text = "کوردستان"
                text = Server.UrlEncode(text)
                Context.RewritePath("/Hewalekan.aspx?cor=1&Title=" + text)
    
            ElseIf varRawUrl.StartsWith("/News/MiddleEast") Then
                Dim text = "ڕۆژهەڵاتی ناوەڕاست"
                text = Server.UrlEncode(text)
                Context.RewritePath("/Hewalekan.aspx?cor=2&Title=‌" + text )
    
            ElseIf varRawUrl.StartsWith("/News/World") Then
                 Dim text = "جیهان"
                text = Server.UrlEncode(text)
                Context.RewritePath("/Hewalekan.aspx?cor=3&Title="+ text)
    
            End If
            
    
        End Sub

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 21, 2018 7:13 AM

All replies

  • User-369506445 posted

    hi

    please try

    string text="مرحبا";
    text=Server.UrlEncode(text);
    string url="http://server/mypage.aspx?qs="+text;
    Response.Redirect(url);

    OR

    putting the following line in my web.config file:

    <globalization fileEncoding="windows-1256" 
        requestEncoding="windows-1256" responseEncoding="windows-1256"/>"
    

    And this <g class="gr_ gr_18 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" id="18" data-gr-id="18">in</g> the head section of my HTML page:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    Wednesday, October 17, 2018 10:10 AM
  • User1456523893 posted

    Hi vahid bakkhi

    iam test but same error 

    Thursday, October 18, 2018 1:30 PM
  • User-893317190 posted

    Hi bryar,

    Could you post the code you have tried?If we could reproduce your problem , it will be easier to  help you solve your problem.

    Best regards,

    Ackerly Xu

    Friday, October 19, 2018 6:57 AM
  • User1456523893 posted

    Code Global.asax

     Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
    
    
    
            Dim varRawUrl As String = HttpContext.Current.Request.RawUrl
    
    
            If varRawUrl.StartsWith("/About") Then
                Context.RewritePath("About.aspx")
    
    
            ElseIf varRawUrl.StartsWith("/News/Kurdistan") Then
                Context.RewritePath("/Hewalekan.aspx?cor=1&Title=کوردستان")
    
            ElseIf varRawUrl.StartsWith("/News/MiddleEast") Then
                Context.RewritePath("/Hewalekan.aspx?cor=2&Title=ڕۆژهەڵاتی ناوەڕاست‌")
    
            ElseIf varRawUrl.StartsWith("/News/World") Then
                Context.RewritePath("/Hewalekan.aspx?cor=3&Title=جیهان")
    
    
            End If
    
    
    
        End Sub
    

    Sunday, October 21, 2018 6:59 AM
  • User-369506445 posted

    please try below

     Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
            
    
            Dim varRawUrl As String = HttpContext.Current.Request.RawUrl
    
    
            If varRawUrl.StartsWith("/About") Then
                Context.RewritePath("About.aspx")
            ElseIf varRawUrl.StartsWith("/News/Kurdistan") Then
                Dim text = "کوردستان"
                text = Server.UrlEncode(text)
                Context.RewritePath("/Hewalekan.aspx?cor=1&Title=" + text)
    
            ElseIf varRawUrl.StartsWith("/News/MiddleEast") Then
                Dim text = "ڕۆژهەڵاتی ناوەڕاست"
                text = Server.UrlEncode(text)
                Context.RewritePath("/Hewalekan.aspx?cor=2&Title=‌" + text )
    
            ElseIf varRawUrl.StartsWith("/News/World") Then
                 Dim text = "جیهان"
                text = Server.UrlEncode(text)
                Context.RewritePath("/Hewalekan.aspx?cor=3&Title="+ text)
    
            End If
            
    
        End Sub

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, October 21, 2018 7:13 AM
  • User1456523893 posted

    Thanks vahid bakkhi 

    Done 

    Sunday, October 21, 2018 9:42 AM