在我的 MVC 应用程序中,电子邮件验证在本地工作得很好,但是当我发布和部署到服务器时它不起作用。我比较了本地和部署文件的html源,没有区别。我的 Razor 视图标记是
<li>
<p><strong>Email: </strong>@Model.CurrentEmailAddress <span class="deliverychange" onclick="showHidden('emailchange');">(Change email)</span></p>
<div id="emailchange" class="fullborder" style="display: none;">
<div class="orderrow newemailaddress">
@Html.LabelFor(m => m.UpdatedEmailAddress)
@Html.TextBoxFor(m => m.UpdatedEmailAddress, new { @onkeypress = "showEmailChangeConfirmation();" })
@Html.ValidationMessageFor(m => m.UpdatedEmailAddress)
</div>
<div id="updatedemailkeypress" style="display: none;">
<div class="orderrow checkboxrow emailchangeconfirm">
@Html.LabelFor(m => m.UpdateEmailAddress)
@Html.EnumRadioButtonFor(m => m.UpdateEmailAddress, false)
</div>
</div>
<div class="clear"> </div>
</div>
</li>
我的模型是
[DataType(DataType.EmailAddress)]
[RegularExpression(@"^([\w.-]+)@([\w-]+)((.(\w){2,3})+)$", ErrorMessage = "Email is not valid")]
[Display(Name = "Enter new email address: ")]
public string UpdatedEmailAddress { get; set; }
[Display(Name = "We will use ****")]
public YesNo UpdateEmailAddress { get; set; }