[英]Checking customer data in ASP.NET MVC
我正在致電控制器,要求其檢查客戶序列號,然后再允許他/她在Zendesk上打開工單(我們需要檢查客戶維護合同是否有效)。 您可以在下面找到代碼。
ActionResult
? 謝謝。
public ActionResult OpenTicket(string serialNumber, string version)
{
if (customerSubscription.IsExpired == false)
{
// need to open this URL
// https://devdept.zendesk.com/tickets/new?ticket[fields[111111]]=" + serialNumber + "&ticket[fields[222222]]=" + version);
}
else
{
// display an error page with upsell options
}
}
要重定向到某些網址,您可以使用基本控制器中的Redirect
方法。 要向視圖返回一些錯誤,您可以在ModelState
上添加錯誤並將其發送給View。 在下面的代碼中添加注釋:
public ActionResult OpenTicket(string serialNumber, string version)
{
if (!customerSubscription.IsExpired)
{
// use the Redirect method from base controller
return Redirect("https://devdept.zendesk.com/tickets/new?ticket[fields[111111]]=" + serialNumber + "&ticket[fields[222222]]=" + version);
}
else
{
// display an error page with upsell options
ModelState.AddModelError("ErrorKey", "Custom error message");
// it will return OpenTicket view, otr pass a name you want to return
return View();
// if you redirect here, you will lose the ModelState.
}
}
您認為,您可以:
@Html.ValidationSummary()
您有2個選項,具體取決於您要撥打外部服務呼叫的位置。
服務器檢測到到期並通知用戶刷新其訂閱。 然后,用戶轉到外部服務URL,刷新訂閱並手動返回到您的站點。
服務器檢測到到期, 自動調用外部服務以刷新用戶的訂閱, 並執行隨后激活用戶訂閱的業務邏輯 。 向用戶提供ActionResult
並進一步進行交互。
案例1:使用重定向並提供外部服務URL
return Redirect(urlString)
情況2:在以下范圍內使用外部服務調用:1.您的控制器或2.委托給business_logic / service層。 對於SOAP通信,請使用svcutil.exe添加服務引用或生成代理,否則,您可以使用HttpWebRequest
( 請參閱參考資料 )。 為了獲得性能,您可以考慮采用異步方法 ,即不阻塞分配用於處理傳入請求的線程。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.