第一次接觸這樣的東西,覺的相當有趣,而最初淺的就是直接看別人怎麼用這個網站的資訊創造出來東西

而身為最「弱」的程式開發員,今天就來試試,當不用前端程式呼叫某個網頁傳回的資料(俗稱Service),該怎麼做?
而一開始要準備好一個Service 網址,可以抓資料回來

//以下所有未加AllowAnonymous者,都一定要經過login 成功才可以進入
[Authorize]
public class MainController : Controller
{
//不一定要經過login 成功才可以進入
[AllowAnonymous]
public ActionResult Login()
{
return View();
}
[AllowAnonymous]
[HttpPost]
public ActionResult Login(Log_Xml logxml)
{
//這邊就會進到Log_Xml 做Validate func
if (!ModelState.IsValid)
{
return View();
}
//要讓會員登入成「已驗證」狀態的話
FormsAuthentication.RedirectFromLoginPage(logxml.Account, false);
return null;
}
[AllowAnonymous]
[HttpPost]
public void LogOut()
{
//清除Session中的資料
Session.Abandon();
//登出表單驗證
FormsAuthentication.SignOut();
//導至登入頁
//return RedirectToAction("Login", "Main");
}
}