我正在开发一个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>
答案 0 :(得分:0)
这基本上是编码问题。阅读更多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
UPDATE @ Broam's答案解决了这个问题
短版:编辑一个文件,选择文件 - &gt;高级保存选项。 而不是将UTF-8更改为Ascii,将其更改为UTF-8。编辑:制作 确保选择没有字节顺序标记(BOM)的选项