0

i upload a file with ASP.net which Contains an "ä" or "ü", when uploaded, on the server the "ä" or "ü" is replaced with another special character. How can i solve this issue. Same Problem is with normal textboxes, so i guess it has to do something with Encoding.

Maybe u have got a solution or an idea, would be quite nice...:-)

1
  • How are you uploading this file? What encoding does the original file use? How are you reading it on the server? What about textboxes? Please provide more context about your scenario and maybe some sample code. Commented May 10, 2011 at 8:58

3 Answers 3

1

Most likely an encoding issue.

You could check:

  • Whether the encoding meta tag on the HTML page is correct.
  • Whether the pages are sending the correct encoding to the client (in the HTTP header)
  • Whether the pages are actually encoded in the correct encoding (via VS.NET "File" menu, menu item "Advanced Save Options").

To see the HTTP headers, use e.g. ieHttpHeaders extension for Internet Explorer.

To change the sent encoding, use either the <globalization> tag in WEB.CONFIG to change for all pages or use the @Page directive to define the response encoding on a per-page-basis.

Sign up to request clarification or add additional context in comments.

Comments

0

put following code in web.config

<configuration>
  <system.web>
    <globalization
      fileEncoding="utf-8"
      requestEncoding="utf-8"
      responseEncoding="utf-8"
      />
  </system.web>
</configuration>

Comments

0

if(File.Exists(Server.MapPath("../App_Data/Karten/") + FileUpload1.PostedFile.FileName.Replace("ö","oe").Replace("Ö","Oe").Replace("Ö","ae").Replace("ä","Ae").Replace("ü","ue").Replace("Ü","Ue"))){ Label1.Text = "Datei existiert bereits"; }else{ string filepath = FileUpload1.PostedFile.FileName; System.Diagnostics.Debug.WriteLine("Filename" + filepath);

        System.Diagnostics.Debug.WriteLine("Filename" + filepath.Replace("ö","oe").Replace("Ö","Oe").Replace("Ö","ae").Replace("ä","Ae").Replace("ü","ue").Replace("Ü","Ue"));
        if (FileUpload1.PostedFile.FileName.ToLower().EndsWith("jpeg") || FileUpload1.PostedFile.FileName.ToLower().EndsWith("jpg"))
        {

        System.Drawing.Image UploadedImage = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);


            if (UploadedImage == null)
              {
                Label1.Text = "Kein Bild";
                System.IO.File.Delete(Server.MapPath("../App_Data/Karten/") + filepath);
            }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.