C# WebAPI控制器邮箱验证接口返回自动重定向HTML页面(原创)
作者:C/S框架网  发布日期:2018/09/25 09:24:42
  C# WebAPI控制器邮箱验证接口返回自动重定向HTML页面(原创)

C# WebAPI控制器邮箱验证接口返回自动重定向HTML页面(原创)

WebApi接口必须返回IHttpActionResult接口类型,并调用ApiController基类的Redirect方法。

参考下面代码:

C# Code:

[HttpGet]
[ActionName("checkemail")]
public IHttpActionResult DoCheckEmail(string id, string email, string scode)
{
   string url1 = "http://www.simidata.com/validateResult.html?result=false & msg=您提交的验证邮箱数据有误!";
   string url2 = "http://www.simidata.com/validateResult.html?result=true & msg=验证邮箱操作成功(Validation Success)!";
   string url3 = "http://www.simidata.com/validateResult.html?result=false & msg=验证邮箱操作失败(Validation Failed)!";
   
   if (string.IsNullOrWhiteSpace(id) || string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(scode))
   return this.Redirect(url1);
   
   bool check = new CmdUserCenter(this.Request, null).CheckEmail(id, email, scode);
   if (check)
   return this.Redirect(url2);
   else
   return this.Redirect(url3);
}

//来源:C/S框架网(www.csframework.com) QQ:23404761



上一篇 下一篇