Page3
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace WebApplication17.Controllers { public class HomeController : Controller { //if write [HttpGet,HttpPost] not work for both post and get public ActionResult Index() { return View(); } [HttpGet] //only work with get , browser url public ActionResult Test() { return TestFunc(); } [HttpPost] //only work with post , called from front in post or Postman [ActionName("Test")] public ActionResult Test_Post() { return TestFunc(); } [NonAction] //not open outside , only call with other backend action public ActionResult TestFunc() { string temp = ""; temp += "URL : " + Request.ServerVariables["URL"] + ""; temp += "REQUEST_METHOD : " + Request.ServerVariables["REQUEST_METHOD"] + ""; temp += "HTTP_USER_AGENT : " + Request.ServerVariables["HTTP_USER_AGENT"] + ""; temp += "REMOTE_ADDR : " + Request.ServerVariables["REMOTE_ADDR"] + ""; ViewBag.page = temp; return View("Test"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace WebApplication17.Controllers { public class HomeController : Controller { //if write [HttpGet,HttpPost] not work for both post and get public ActionResult Index() { return View(); } [HttpGet] //only work with get , browser url public ActionResult Test() { return TestFunc(); } [HttpPost] //only work with post , called from front in post or Postman [ActionName("Test")] public ActionResult Test_Post() { return TestFunc(); } [NonAction] //not open outside , only call with other backend action public ActionResult TestFunc() { string temp = ""; temp += "URL : " + Request.ServerVariables["URL"] + ""; temp += "REQUEST_METHOD : " + Request.ServerVariables["REQUEST_METHOD"] + ""; temp += "HTTP_USER_AGENT : " + Request.ServerVariables["HTTP_USER_AGENT"] + ""; temp += "REMOTE_ADDR : " + Request.ServerVariables["REMOTE_ADDR"] + ""; ViewBag.page = temp; return View("Test"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace WebApplication17.Controllers { public class HomeController : Controller { //if write [HttpGet,HttpPost] not work for both post and get public ActionResult Index() { return View(); } [HttpGet] //only work with get , browser url public ActionResult Test() { return TestFunc(); } [HttpPost] //only work with post , called from front in post or Postman [ActionName("Test")] public ActionResult Test_Post() { return TestFunc(); } [NonAction] //not open outside , only call with other backend action public ActionResult TestFunc() { string temp = ""; temp += "URL : " + Request.ServerVariables["URL"] + ""; temp += "REQUEST_METHOD : " + Request.ServerVariables["REQUEST_METHOD"] + ""; temp += "HTTP_USER_AGENT : " + Request.ServerVariables["HTTP_USER_AGENT"] + ""; temp += "REMOTE_ADDR : " + Request.ServerVariables["REMOTE_ADDR"] + ""; ViewBag.page = temp; return View("Test"); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace WebApplication17.Controllers { public class HomeController : Controller { //if write [HttpGet,HttpPost] not work for both post and get public ActionResult Index() { return View(); } [HttpGet] //only work with get , browser url public ActionResult Test() { return TestFunc(); } [HttpPost] //only work with post , called from front in post or Postman [ActionName("Test")] public ActionResult Test_Post() { return TestFunc(); } [NonAction] //not open outside , only call with other backend action public ActionResult TestFunc() { string temp = ""; temp += "URL : " + Request.ServerVariables["URL"] + ""; temp += "REQUEST_METHOD : " + Request.ServerVariables["REQUEST_METHOD"] + ""; temp += "HTTP_USER_AGENT : " + Request.ServerVariables["HTTP_USER_AGENT"] + ""; temp += "REMOTE_ADDR : " + Request.ServerVariables["REMOTE_ADDR"] + ""; ViewBag.page = temp; return View("Test"); } } }