void DeletePage() { if (System.IO.File.Exists(MaUrl.Current.SavePath)) { if (MaWebUtility.IPAuthentication()) { //删除页面,安全Ip System.IO.File.Delete(MaUrl.Current.SavePath); HttpContext.Current.Response.Write("删除成功!" + m_requestViewInfo); HttpContext.Current.Response.End(); } else { HttpContext.Current.Response.StatusCode = 505; HttpContext.Current.Response.End(); } } HttpContext.Current.Response.Write("没有此文件!"); HttpContext.Current.Response.End(); }
void UpdatePage() { if (MaWebUtility.IPAuthentication()) { if (System.IO.File.Exists(MaUrl.Current.SavePath)) { //删除页面,安全Ip System.IO.File.Delete(MaUrl.Current.SavePath); } HttpResponse.RemoveOutputCacheItem(MaUrl.Current.AbsolutePath + "l"); HttpContext.Current.Response.Charset = "UTF-8"; HttpContext.Current.Response.ContentType = "text/html;charset=utf-8"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8; HttpContext.Current.Response.Write("页面更新成功!" + m_requestViewInfo); HttpContext.Current.Response.End(); } else { HttpContext.Current.Response.StatusCode = 505; HttpContext.Current.Response.End(); } }
void NullPage() { if (System.IO.File.Exists(MaUrl.Current.SavePath)) { if (MaWebUtility.IPAuthentication()) { //清空页面,安全Ip System.IO.File.Delete(MaUrl.Current.SavePath); System.IO.File.WriteAllText(MaUrl.Current.SavePath, ""); HttpContext.Current.Response.Write("清空页面成功!" + m_requestViewInfo); HttpContext.Current.Response.End(); } else { HttpContext.Current.Response.StatusCode = 505; HttpContext.Current.Response.End(); } } else { HttpContext.Current.Response.Write("没有原始文件!" + m_requestViewInfo); HttpContext.Current.Response.End(); } }
void context_PostAuthorizeRequest(object sender, EventArgs e) { //在当前请求的用户已获授权时发生。 if (MaUrl.Current.RequestType == MaRequestType.HTM) { #region 访问静态文件 if (MaUrl.Current.RequestFilePathExtension == ".htm") { if (!System.IO.File.Exists(MaUrl.Current.SavePath)) { //静态文件不存在,重写URL HttpContext.Current.RewritePath(MaUrl.Current.AbsolutePath + "l", true); } } #endregion if (MaUrl.Current.RequestView != MaRequestView.Put) { //进行安全认证 if (!MaWebUtility.IPAuthentication()) { HttpContext.Current.Response.Redirect("/index.html?command_error=true"); HttpContext.Current.Response.End(); } else { switch (MaUrl.Current.RequestView) { case MaRequestView.Put: { //HtmxFilter中实现 } break; case MaRequestView.Edit: break; case MaRequestView.Update: UpdatePage(); break; case MaRequestView.Delete: DeletePage(); break; case MaRequestView.Save: { //HtmxFilter中实现 } break; case MaRequestView.Null: NullPage(); break; case MaRequestView.Cache: CachePage(); break; default: break; } } } } }