0

我不知道如何提出这个问题,甚至想不出合适的标题,但我会一步一步来。
我有一个休息服务项目,还有一个 MVC3 项目。
我的 MVC3 项目通过 ajax 访问其余服务。
即:内部mvc视图

<script type="text/javascript">
    $(document).ready(function () {
        $("#submit").click(function () {
            $.ajax({
                url: 'http://localhost:2222/RestService/User/Register',
                type: 'POST',
                contentType: 'application/json',
                data: JSON.stringify({
                    RollNumber: $("#username").val(),
                    Email: $("#email-address").val(),
                    Password: $("#password").val(),
                    Birthday: $("#bday").val()
                }),
                success: function (response) {
                    if (response == true) {
                        window.location.replace('@Url.Action("Index", "Home")');
                    } else {
                        showtooltip('Registration failed.');
                    }
                },
                error: function (xhr, ajaxOptions, error) {
                    showtooltip(xhr.status + ': ' + error);
                }
            });
        });
    });
</script>  

如果用户注册成功,mvc 会自动发送一封邮件。
即:电子邮件内容示例:

WELCOME TO NEWWEBSITE!

You have successfully registered!
.
.
.
To validate your email address, please go to the link below:

http://localhost:1111/NewWebsite/Auth/Verify?verificationid=3DE4ED727750215957F8A1E4B117C38E7250C33&email=sampleemail%40yahoo.com  

然后我不知道下一步该怎么做。
如果用户点击链接来验证他的帐户,我如何从链接中获取信息?

我创建了一个用于验证的 Rest 服务

[WebGet(UriTemplate = "RestService/User/Verify?verificationid={verificationid}&email={email}", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
public bool VerifyAccount(string verificationid, string email)
{
    RestLogicClass.RestLogic.UserComponent svc = new RestLogicClass.RestLogic.UserComponent();
    return svc.ValidateEmail(new RestLogicClass.Entities.UserEmail() { EmailAddress = HttpUtility.HtmlDecode(email), ValidateKey = verificationid });
}  

可以通过以下方式调用此服务:

http://localhost:2222/RestService/User/Verify?verificationid={verificationid}&email={email}  

如果电子邮件已经过验证,那么它必须向用户显示来自 mvc 的“Verify.cshtml”页面。
可以通过以下方式访问此页面:

http://localhost:1111/NewWebsite/Auth/Verify  

希望你明白我的解释。我是这种数据处理的新手,所以如果您有更好的想法,请分享。

4

1 回答 1

0

为了显示Verify.cshtml。我认为你应该有一个动作名称

public ActionResult Verify(string verificationid, string email)
{
    //// call the service from here and validate 
    //// if valid then return View();
}  

此外,当您生成电子邮件时,请使用此 url 生成。

于 2012-04-12T10:32:20.240 回答