- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在 C# MVC 应用程序中编写了以下用于重置用户密码的代码(我使用的是 aspnet 成员(member) api),并在示例教程应用程序(MVC 音乐商店)上成功测试。如果您想先阅读问题描述,请跳到最后。
InactiveUsers View (部分 View )
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.Web.Security.MembershipUserCollection>" %>
<table class="normal" style="width: 100%; background-color: White;">
<tr>
<th>User Name</th>
<th>Last Activity date</th>
<th>Locked Out</th>
</tr>
<%foreach (MembershipUser user in Model){ %>
<tr>
<td><%: Html.RouteLink(user.UserName, "AdminPassword", new { username = user.UserName }) %></td>
<td><%: user.LastActivityDate %></td>
<td><%: user.IsLockedOut %></td>
</tr>
<% }%>
</table>
InactiveUsers Controller
public ActionResult InactiveUsers()
{
var users = Membership.GetAllUsers();
return View(users);
}
changeUserPassword GET 和 POST Controller
public ActionResult changeUserPassword(string username)
{
ViewData["username"] = username;
return View();
}
[HttpPost]
public ActionResult changeUserPassword(ChangePasswordModel model, FormCollection values)
{
string username = values["username"];
string password = values["password"];
string confirmPassword = values["confirmPassword"];
MembershipUser mu = Membership.GetUser(username);
if (password == confirmPassword)
{
if (mu.ChangePassword(mu.ResetPassword(), password))
{
return RedirectToAction("Index", "ControlPanel");
}
else
{
ModelState.AddModelError("", "The current password does not meet requirements");
}
}
return View();
}
我还修改了 Global.asax.cs 文件以适应我在 InactiveUsers 部分中的路由:
// Added in 10/01/11
RouteTable.Routes.MapRoute(
"AdminPassword", // routename
"ControlPanel/changeUserPassword/{username}",
new { controller = "ControlPanel", action = "changeUserPassword", username = UrlParameter.Optional }
);
// END
现在,当我在 MVC 音乐商店上进行测试时,我所有的用户名都只是单词,例如管理员、用户等。但是,现在我将这段代码应用到我工作场所的一个情况中,但它并没有按计划运行。我工作场所使用的用户名实际上是电子邮件地址,我认为这就是导致问题的原因。
当我在部分 InactiveUsers View 中单击 RouteLink 时,它应该将我带到重置密码页面,其 url 如下所示:
http://localhost:83/ControlPanel/changeUserPassword/example1@gmail.com , 然而,
当我点击 RouteLink 时发生了一个错误,提示无法找到 View changeUserPassword,URL 如下所示:
http://localhost:83/ControlPanel/changeUserPassword/example1%40gmail.com - 看看“@”符号是如何弄乱的?
我还调试了代码,在我的 GET changeUserPassword 中,用户名填充正确:example1@gmail.com,所以我认为只是 URL 搞砸了?
如果我手动输入 URL,会显示 changeUserPassword View ,但密码重置功能不起作用。在 if (mu.ChangePassword(mu.ResetPassword(), password)) 行抛出“未设置对象实例的对象引用”异常。
我想如果我能解决第一个问题(URL '@' 符号问题),它可能会帮助我解决第二个问题。
任何帮助将不胜感激:)
堆栈跟踪 - 根据要求
来源错误:
在执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常起源和位置的信息。
堆栈跟踪:
[InvalidOperationException: The view 'changeUserPassword' or its master was not found. The following locations were searched:
~/Views/ControlPanel/changeUserPassword.aspx
~/Views/ControlPanel/changeUserPassword.ascx
~/Views/Shared/changeUserPassword.aspx
~/Views/Shared/changeUserPassword.ascx]
System.Web.Mvc.ViewResult.FindView(ControllerContext context) +495
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39
System.Web.Mvc.<>c__DisplayClass14.<InvokeActionResultWithFilters>b__11() +60
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +391
System.Web.Mvc.<>c__DisplayClass16.<InvokeActionResultWithFilters>b__13() +61
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +285
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +830
System.Web.Mvc.Controller.ExecuteCore() +136
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +111
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +39
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +65
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +44
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +42
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +141
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +54
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +52
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
最佳答案
你知道 %40 是 @ 符号的 URL 编码版本吗?您的 URL 中的数据没有弄乱,它是 URL 编码的。这是必需的,因为您的数据包含一个在 URL 中有意义的符号,因此必须以不破坏 URL 的方式对其进行编码。
您可以在这里尝试 URL 编码/解码: http://meyerweb.com/eric/tools/dencoder/
关于C#MVC : User Password Reset Controller: Issues with email addresses as usernames,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4645635/
我有一个 postfix 电子邮件服务器,有一个问题我想调试。 我如何配置它以将每封电子邮件的副本发送到我的电子邮件(除了将电子邮件发送给其预期收件人)。 最佳答案 我最近开始工作了,所以尽管我会分享
我的 Web 应用程序发送电子邮件的频率相当高,它发送 3 种电子邮件:由用户发起、响应系统中的事件以及自动响应应用程序收到的电子邮件。 我想确保第三种类型的电子邮件不会陷入自动回复器相互交谈的无限循
我家里有一台电脑,但我无法在工作中使用它。我希望能够查看我的家用计算机生成的工作结果。我想出的最好的主意是在我的家用计算机上运行一个自动脚本,它在完成后通过电子邮件将结果(来自文本文件或 stderr
我在 Google App Engine 上编写了一个应用程序,可以将电子邮件发送到一个地址。应用程序在测试期间达到了它的“通过电子邮件发送的收件人”配额限制。对于“已发送电子邮件的收件人”配额,是否
我的代码循环发送多封带附件的电子邮件, 问题是最后(之前的所有)电子邮件的附件附加到下一封电子邮件。 例如。假设数据库中有 3 封电子邮件,每封邮件有 1 个附件(a1.pdf、a2.pdf、a3.p
我的应用程序使用电子邮件通知我重要事件。它通过将电子邮件发送到我的电子邮件地址(标记为应用程序的所有者)来这样做(使用 Python 运行时)。 免费层允许每天向收件人发送 100 封电子邮件,但向管
我们在 VPS 上使用 exim。我们在 WP 和 Magento 上托管多个域。 最近,当我在 Received 标题中看到以下内容时,我正在查看一些电子邮件:我的 linux 用户名、服务器名(不
官方格式是什么 name 在电子邮件标题中?我需要先验证用户输入,然后再将其粘贴到标题中。 另外,您是否碰巧知道好的正则表达式来验证名称+电子邮件对的形式? 最佳答案 Enjoy. 在stackov
我在很多地方都看到过这种问题,但还没有找到真正的答案。 有谁知道如何使用 html.jelly 模板使构建日志显示在正文中,而不是全部一起运行并实际用换行符分隔每一行? 我很确定答案在于需要对模板进行
我正在使用 Jenkins 2.2 和 email-ext plugin 2.42(两者都是最新的,我的所有其他插件也是如此)。我将全局配置设置为具有单个显式收件人,并且我的项目使用默认电子邮件通知配
使用 symfony 框架如何从本地主机发送测试电子邮件? 最简单的方法是什么? 谢谢! 最佳答案 我认为最简单的方法(也是我通常做的)是配置 _dev 环境以使用旧版 Gmail(或任何其他提供商)
使用 symfony 框架如何从本地主机发送测试电子邮件? 最简单的方法是什么? 谢谢! 最佳答案 我认为最简单的方法(也是我通常做的)是配置 _dev 环境以使用旧版 Gmail(或任何其他提供商)
我正在使用 sendgrid 发送电子邮件。但是当我尝试按如下方式创建电子邮件对象时 let email = new sendgrid.Email(); email.addTo("rhushikesh
谷歌在这里不是很有帮助。我想用 :set spell 撰写电子邮件上,但对于所有其他文件,:set spell应该关闭。我正在使用 mutt 和 Vim 作为撰写电子邮件的编辑器。 事实上,我很好奇,
我目前在 Windows 7 中使用 Jenkins。 我最近在 jenkins 中运行了一些构建。我能够通过 SVN Post commit 运行构建。 现在我必须通过电子邮件在 Jenkins 中
到目前为止,我已经制作了一个带有登录/注册功能的应用程序,它运行良好。 注册后会发送欢迎电子邮件。 但是我想要做的是在该邮件中发送一个链接,只有在单击它后才能登录。 比如论坛常用的注册邮箱等。 有人可
我工作的公司为医疗保健行业提供测试服务。作为我们服务的一部分,我们需要向客户的员工发送电子邮件。通常,这些人是临时工、兼职人员或契约(Contract)工,因此拥有私有(private)电子邮件地址(
我正在尝试通过 Twitter API 找人。我使用这样的网址:https://api.twitter.com/1/users/search.json?q=some@email.com但是有一个问题。
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
我正在使用名为 email-ext 的 Jenkins 插件我想让 Jenkins 发送一封由 html.jelly 生成的电子邮件位于 $JENKINS_HOME/email-templates 中
我是一名优秀的程序员,十分优秀!