ASP.Net mvc5 我的网站不允许 'åäö'
ASP.Net mvc5 my site dosen't allow 'åäö'
我正在开发一个 asp.net mvc5 项目,我只是注意到它不允许我很好地使用 'åäö' 它允许我使用这些字符,但它显示如下。 'ä' 等等。
奇怪的是,我可以在导航栏中使用字符,但在页面上却不允许。
这是我的登录页面:
应该说 "Användarnamn" 和 "Lösenord"。
但它是我的导航栏,它工作正常..
这是我共享的_Layout,每个站点都继承自
<!DOCTYPE html>
<html lang="sv">
<head>
<title>Treetop @ViewBag.Title</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/modernizr")
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css"/>
</head>
<body>
@if (User.Identity.IsAuthenticated)
{
<div class="page-header">
<div class="page-header-top">
<div class="container">
<div class="page-logo">
<h3>Treetop Innovation</h3>
</div>
<a href="javascript:;" class="menu-toggler"></a>
</div>
</div>
<div class="page-header-menu">
<div class="container">
<div class="hor-menu ">
<ul class="nav navbar-nav">
<li>
@Html.ActionLink("Ny Rapport", "TimeReport", "Reports")
</li>
<li>
@Html.ActionLink("Rappotera frånvaro", "Absent", "Reports")
</li>
<li>
@Html.ActionLink("Rapporter", "Index", "Reports")
</li>
<li>
@Html.ActionLink("Inställningar", "Settings", "Reports")
</li>
<li>
@Html.ActionLink("Mina projekt", "Index", "Projects")
</li>
<li>
@Html.ActionLink("Begär semester", "Index", "Vacation")
</li>
</ul>
</div>
<div class=" hor-menu nav navbar-nav pull-right">
<ul class="nav navbar-nav">
<li><a>@User.Identity.Name</a></li>
<li>
@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
@Html.AntiForgeryToken()
<a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
}
</li>
</ul>
</div>
</div>
</div>
</div>
<script>
jQuery(document).ready(function () {
Metronic.init();
Layout.init();
Demo.init();
ComponentsPickers.init();
TableAdvanced.init();
});
</script>
}
@RenderBody()
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/modernizr")
@RenderSection("scripts", required: false)
</body>
</html>
这是行不通的观点:
<body class="login">
<div class="logo">
<h3 style="color: white">Treetop Innovation</h3>
</div>
<div class="content">
@using (Html.BeginForm("LogOn", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "login-form", role = "form" }))
{
@Html.AntiForgeryToken()
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span>
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
</span>
</div>
<h3 class="form-title">Logga in</h3>
<div class="form-group">
<div class="input-icon">
<i class="fa fa-user"></i>
@Html.TextBoxFor(m => m.UserName, new { @class = "form-control", placeholder = "Användarnamn" })
</div>
@Html.ValidationMessageFor(m => m.UserName, "", new { @class = "text-danger" })
</div>
<div class="form-group">
<div class="input-icon">
<i class="fa fa-lock"></i>
@Html.PasswordFor(m => m.Password, new { @class = "form-control", placeholder = "Lösenord" })
</div>
@Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
</div>
<div class="form-actions">
<div class="checkbox" style="padding: 0 20px">
@Html.CheckBoxFor(m => m.RememberMe)
Kom ihåg
</div>
<button type="submit" class="btn green-haze pull-right">
Login <i class="fa fa-arrow-right"></i>
</button>
</div>
}
</div>
</body>
这基本上是一个编码问题。阅读更多 There Ain't No Such Thing as Plain Text
Användarnamn = Användarnamn
和
Lösenord = Lösenord
您可以对这些特殊字符使用 HTML 实体或 ISO Latin-1 代码。
https://www.utexas.edu/learn/html/spchar.html
更新
@Broam's 解决问题的答案
Short version: edit one file, select File -> Advanced Save Options.
Instead of changing UTF-8 to Ascii, change it to UTF-8. Edit: Make
sure you select the option that says no byte-order-marker (BOM)
您必须使用正确的编码保存 .cshtml
文件。
文件 > 另存为 MyFile.cshtml 为...
选择使用编码保存...
选择是替换它。
选择 UTF-8。
我正在开发一个 asp.net mvc5 项目,我只是注意到它不允许我很好地使用 'åäö' 它允许我使用这些字符,但它显示如下。 'ä' 等等。
奇怪的是,我可以在导航栏中使用字符,但在页面上却不允许。
这是我的登录页面:
应该说 "Användarnamn" 和 "Lösenord"。
但它是我的导航栏,它工作正常..
这是我共享的_Layout,每个站点都继承自
<!DOCTYPE html>
<html lang="sv">
<head>
<title>Treetop @ViewBag.Title</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/modernizr")
<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css"/>
</head>
<body>
@if (User.Identity.IsAuthenticated)
{
<div class="page-header">
<div class="page-header-top">
<div class="container">
<div class="page-logo">
<h3>Treetop Innovation</h3>
</div>
<a href="javascript:;" class="menu-toggler"></a>
</div>
</div>
<div class="page-header-menu">
<div class="container">
<div class="hor-menu ">
<ul class="nav navbar-nav">
<li>
@Html.ActionLink("Ny Rapport", "TimeReport", "Reports")
</li>
<li>
@Html.ActionLink("Rappotera frånvaro", "Absent", "Reports")
</li>
<li>
@Html.ActionLink("Rapporter", "Index", "Reports")
</li>
<li>
@Html.ActionLink("Inställningar", "Settings", "Reports")
</li>
<li>
@Html.ActionLink("Mina projekt", "Index", "Projects")
</li>
<li>
@Html.ActionLink("Begär semester", "Index", "Vacation")
</li>
</ul>
</div>
<div class=" hor-menu nav navbar-nav pull-right">
<ul class="nav navbar-nav">
<li><a>@User.Identity.Name</a></li>
<li>
@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
@Html.AntiForgeryToken()
<a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
}
</li>
</ul>
</div>
</div>
</div>
</div>
<script>
jQuery(document).ready(function () {
Metronic.init();
Layout.init();
Demo.init();
ComponentsPickers.init();
TableAdvanced.init();
});
</script>
}
@RenderBody()
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/modernizr")
@RenderSection("scripts", required: false)
</body>
</html>
这是行不通的观点:
<body class="login">
<div class="logo">
<h3 style="color: white">Treetop Innovation</h3>
</div>
<div class="content">
@using (Html.BeginForm("LogOn", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "login-form", role = "form" }))
{
@Html.AntiForgeryToken()
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span>
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
</span>
</div>
<h3 class="form-title">Logga in</h3>
<div class="form-group">
<div class="input-icon">
<i class="fa fa-user"></i>
@Html.TextBoxFor(m => m.UserName, new { @class = "form-control", placeholder = "Användarnamn" })
</div>
@Html.ValidationMessageFor(m => m.UserName, "", new { @class = "text-danger" })
</div>
<div class="form-group">
<div class="input-icon">
<i class="fa fa-lock"></i>
@Html.PasswordFor(m => m.Password, new { @class = "form-control", placeholder = "Lösenord" })
</div>
@Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
</div>
<div class="form-actions">
<div class="checkbox" style="padding: 0 20px">
@Html.CheckBoxFor(m => m.RememberMe)
Kom ihåg
</div>
<button type="submit" class="btn green-haze pull-right">
Login <i class="fa fa-arrow-right"></i>
</button>
</div>
}
</div>
</body>
这基本上是一个编码问题。阅读更多 There Ain't No Such Thing as Plain Text
Användarnamn = Användarnamn
和
Lösenord = Lösenord
您可以对这些特殊字符使用 HTML 实体或 ISO Latin-1 代码。
https://www.utexas.edu/learn/html/spchar.html
更新 @Broam's 解决问题的答案
Short version: edit one file, select File -> Advanced Save Options. Instead of changing UTF-8 to Ascii, change it to UTF-8. Edit: Make sure you select the option that says no byte-order-marker (BOM)
您必须使用正确的编码保存 .cshtml
文件。
文件 > 另存为 MyFile.cshtml 为...
选择使用编码保存...
选择是替换它。
选择 UTF-8。