文件名称:IHTTPModel接口实现文件上传
文件大小:54KB
文件格式:DOC
更新时间:2012-06-26 02:38:49
文件上传
void context_BeginRequest(object sender, EventArgs e) { #region 初始化,决定是否要求处理 HttpApplication m_application = sender as HttpApplication; IServiceProvider m_provider = HttpContext.Current; HttpWorkerRequest m_workRequest = (HttpWorkerRequest)m_provider.GetService(typeof(HttpWorkerRequest)); string m_contentType = m_application.Request.ContentType; if (!m_contentType.StartsWith("multipart/form-data", StringComparison.OrdinalIgnoreCase)) return; if (!m_workRequest.HasEntityBody()) return; #endregion #region 获取分隔符 string m_boundaryStr = m_contentType.Substring(m_contentType.IndexOf("boundary=", 0, StringComparison.OrdinalIgnoreCase) + 9); byte[] m_boundaryData = Encoding.ASCII.GetBytes("\r\n--" + m_boundaryStr); #endregion