routes.IgnoreRoute("*.html")
原理是只要看到*.html的要求,則忽略路由規則,不會去找對應的Controller -> Action
[Reference]:
ViewContext.Controller.ValueProvider.GetValue("action").RawValue
ViewContext.Controller.ValueProvider.GetValue("controller").RawValue
ViewContext.Controller.ValueProvider.GetValue("id").RawValueViewContext.Controller.ValueProvider["controller"].RawValue
ViewContext.Controller.ValueProvider["id"].RawValue
|
public class NoCacheAttribute : System.Web.Mvc.ActionFilterAttribute
{
public override void OnResultExecuting(System.Web.Mvc.ResultExecutingContext filterContext)
{
filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
filterContext.HttpContext.Response.Cache.SetNoStore();
base.OnResultExecuting(filterContext);
}
}
[NoCache]
public class AController : Controller
{
[NoCache]
public ActionResult Index()
{
return View();
}
}
jQuery(document).ready(function () {
ajax_updatePartial('<%= Url.Content("~/Manager/Student/")%>' + '<%: Model.Id %>');
});
function ajax_updatePartial(path){
$.ajax ({
url: path,
success: function(result) {
$('#AjaxStudentInClassPartial').html(result);
}
});
return false;
}
using (Entites db = new Entites())
{
var result = (from s in db.Person.Include("Weapon") select s).ToList();
return View(result);
}
return View();
<% foreach (var item in Model) { %>
<%: Html.DropDownListFor(s=>s.Person.Where(a=>a.WeaponID == item.WeaponID).WeaponID ,
new SelectList(MyApplication.Models.DropDownList.GetDropDownList(), "Value", "Text", item.WeaponID )%>
><% } %>
class DropDownList
{
public List GetDropDownList()
{
List result = new List();
result.Add(new System.Web.Mvc.SelectListItem
{
Value = "1",
Text = "Apple"
});
result.Add(new System.Web.Mvc.SelectListItem
{
Value = "2",
Text = "Milk"
});
return result;
}
}
public ActionResult Image(string id)
{
var dir = Server.MapPath("/Images");
var path = Path.Combine(dir, id + ".jpg");
return base.File(path, "image/jpeg");
}
$('#dialog').parent().appendTo($('#PostForm'));