Reputation: 1331
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...:-)
Upvotes: 0
Views: 1417
Reputation: 1331
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);
}
Upvotes: 0
Reputation: 28672
put following code in web.config
<configuration>
<system.web>
<globalization
fileEncoding="utf-8"
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
</system.web>
</configuration>
Upvotes: 0
Reputation: 40746
Most likely an encoding issue.
You could check:
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.
Upvotes: 1