本文整理汇总了C#中System.Web.HttpContext类的典型用法代码示例。如果您正苦于以下问题:C# HttpContext类的具体用法?C# HttpContext怎么用?C# HttpContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpContext类属于System.Web命名空间,在下文中一共展示了HttpContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.ClearHeaders();
context.Response.Clear();
context.Response.ContentType = "text/xml";
SerializeMetadata(context.Response.OutputStream);
}
开发者ID:aduggleby,项目名称:dragon,代码行数:7,代码来源:FederationMetadataHandler.cs
示例2: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/javascript";
if (!context.IsDebuggingEnabled)
context.Response.SetOutputCache(DateTime.Now.AddHours(1));
context.Response.Write("(function (module) {");
context.Response.Write(@"
module.factory('Translate', function () {
return function (key, fallback) {
var t = translations;
var k = key.split('.');
for (var i in k) {
t = t[k[i]];
if (!t) return fallback;
}
return t;
}
});
");
context.Response.Write("var translations = ");
var jsPath = context.Request.AppRelativeCurrentExecutionFilePath.Substring(0, context.Request.AppRelativeCurrentExecutionFilePath.Length - 5);
var file = HostingEnvironment.VirtualPathProvider.GetFile(jsPath);
using (var s = file.Open())
{
TransferBetweenStreams(s, context.Response.OutputStream);
}
context.Response.Write(";" + Environment.NewLine);
context.Response.Write("module.value('n2translations', translations);");
context.Response.Write("})(angular.module('n2.localization', []));");
}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:34,代码来源:AngularLocalizationHandler.cs
示例3: ProcessRequest
public void ProcessRequest(HttpContext context)
{
string username = context.Request.Params["username"];
string password = context.Request.Params["password"];
if (String.IsNullOrEmpty(username) || String.IsNullOrEmpty(password))
return;
List<ICriterion> criterionList = new List<ICriterion>();
criterionList.Add(Restrictions.Eq("UserName", username));
criterionList.Add(Restrictions.Eq("Password", password));
QueryTerms queryTerms = new QueryTerms();
queryTerms.CriterionList = criterionList;
queryTerms.PersistentClass = typeof(SystemUser);
List<SystemUser> userList = (List<SystemUser>)SystemUserBll.GetSystemUserList(queryTerms, false).Data;
string script = "";
if (userList == null || userList.Count != 1)
{
script = "$('#messageSpan').html(''); setTimeout(\"$('#messageSpan').html('用户名或密码错误……');\", 50);";
}
else
{
HttpContext.Current.Session["SystemUser"] = userList[0];
script = "location.href='Default.htm';";
}
context.Response.Write(script);
}
开发者ID:ZeeMenng,项目名称:HealthManagement,代码行数:30,代码来源:LoginApp.ashx.cs
示例4: ProcessRequest
public override void ProcessRequest(HttpContext context)
{
base.ProcessRequest(context);
context.Response.ContentType = "application/json";
string opr = context.Request["opr"] + "";
switch (opr)
{
case "addMaterialPrice"://添加
addMaterialPrice(context);
break;
case "getMaterialPriceList":
getMaterialPrice(context);
break;
case "getSuppliersList":
getSuppliersList(context);
break;
case "getMaterialList":
getMaterialList(context);
break;
case "editMaterialPrice":
editMaterialPrice(context);
break;
case "delMaterialPrice":
delMaterialPrice(context);
break;
case "getPriceRecord":
getPriceRecord(context);
break;
}
}
开发者ID:monkinone,项目名称:OrderPrinnt,代码行数:30,代码来源:MaterialPriceManage.ashx.cs
示例5: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Clear();
if (context.Request.Files.Count > 0)
{
try
{
HttpPostedFile httpPostFile = context.Request.Files[0];
string file = context.Request.Form["Filename"].ToString();
string fileType = file.Substring(file.LastIndexOf('.')).ToLower();
Random r = new Random();
string fileName = DateTime.Now.ToString("yyyyMMdd-HHmmss-ms") + r.Next(100, 999) + fileType;
string serverPath = System.Configuration.ConfigurationSettings.AppSettings["ImageUploadPath"];
httpPostFile.SaveAs(context.Server.MapPath(serverPath + fileName));
context.Application["ImageUrl"] = serverPath + fileName;
context.Response.Write("UP_OK");
}
catch
{
context.Response.Write("UP_FAILE");
}
}
else
{
context.Response.Write("UP_FAILE");
}
}
开发者ID:ErekTan,项目名称:HLedo,代码行数:28,代码来源:UploadImage.ashx.cs
示例6: Delete
public static ReturnObject Delete(HttpContext context, long id)
{
if (id <= 0)
return new ReturnObject() { Error = true, Message = "Invalid Drug Company." };
var item = new Lib.Data.DrugCompany(id);
item.Delete();
return new ReturnObject()
{
Growl = new ReturnGrowlObject()
{
Type = "default",
Vars = new ReturnGrowlVarsObject()
{
text = "You have successfully deleted a drug company.",
title = "Drug Company Deleted"
}
},
Actions = new List<ReturnActionObject>()
{
new ReturnActionObject() {
Ele = "#companies-table tr[data-id=\""+id.ToString()+"\"]",
Type = "remove"
}
}
};
}
开发者ID:REMSLogic,项目名称:REMSLogic,代码行数:28,代码来源:Company.cs
示例7: GenerateOutput
public string GenerateOutput(HttpContext context, Config c)
{
StringBuilder sb = new StringBuilder();
//Figure out CustomErrorsMode
System.Configuration.Configuration configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
CustomErrorsSection section = (configuration != null) ? section = (CustomErrorsSection)configuration.GetSection("system.web/customErrors") : null;
CustomErrorsMode mode = (section != null) ? section.Mode : CustomErrorsMode.RemoteOnly;
//What is diagnostics enableFor set to?
DiagnosticMode dmode = c.get<DiagnosticMode>("diagnostics.enableFor", DiagnosticMode.None);
//Is it set all all?
bool diagDefined = (c.get("diagnostics.enableFor",null) != null);
//Is it available from localhost.
bool availLocally = (!diagDefined && mode == CustomErrorsMode.RemoteOnly) || (dmode == DiagnosticMode.Localhost);
sb.AppendLine("The Resizer diagnostics page is " + (availLocally ? "only available from localhost." : "disabled."));
sb.AppendLine();
if (diagDefined) sb.AppendLine("This is because <diagnostics enableFor=\"" + dmode.ToString() + "\" />.");
else sb.AppendLine("This is because <customErrors mode=\"" + mode.ToString() + "\" />.");
sb.AppendLine();
sb.AppendLine("To override for localhost access, add <diagnostics enableFor=\"localhost\" /> in the <resizer> section of Web.config.");
sb.AppendLine();
sb.AppendLine("To ovveride for remote access, add <diagnostics enableFor=\"allhosts\" /> in the <resizer> section of Web.config.");
sb.AppendLine();
return sb.ToString();
}
开发者ID:eakova,项目名称:resizer,代码行数:26,代码来源:DiagnosticDisabledHandler.cs
示例8: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.StatusCode = 200;
context.Response.ContentType = "text/plain";
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.Write(GenerateOutput(context, c));
}
开发者ID:eakova,项目名称:resizer,代码行数:7,代码来源:DiagnosticDisabledHandler.cs
示例9: ProcessRequest
public void ProcessRequest(HttpContext context)
{
var caller = Utilities.GetServicesAction(context);
HandlerContainer container;
if (!string.IsNullOrEmpty(caller.Name) && _handler.TryGetValue(caller.Name, out container))
{
int step = 0;
try
{
ServicesResult result = null;
HandlerMethodInfo mi;
if (container.Methods.TryGetValue(caller.Method, out mi))
{
var ticket = context.Request["__t"];
if (!string.IsNullOrEmpty(ticket))
{
step = 1;
AppContextBase.SetFormsAuthenticationTicket(ticket);
}
step = 2;
object obj;
if (mi.IsHttpContextArg && mi.ArgCount == 1)
obj = mi.Method.Invoke(container.Handler, new object[] { context });
else if (mi.ArgCount == 0)
obj = mi.Method.Invoke(container, null);
else
obj = mi.Method.Invoke(container, new object[mi.ArgCount]);
if (mi.ResultType != ServicesResult.ResultType.ServicesResultType && obj != null)
{
result = ServicesResult.GetInstance(0, "Method execute successfuly", obj);
}
else if (obj != null)
{
result = (ServicesResult)obj;
}
}
else
throw new Exception("Unkonw method info...");
if (result != null)
{
//context.Response.Write(result);
OutputResult(context, result);
}
}
catch (Exception ex)
{
if (step == 1)
OutputResult(context, Utilities.GetWebServicesResult(-100, "你的登录已过期,请重新登录."));
else if (ex.InnerException != null)
OutputResult(context, (Utilities.GetWebServicesResult(-1, ex.InnerException.Message.Trim('\n', '\r'))));
else
OutputResult(context, (Utilities.GetWebServicesResult(-1, ex.Message.Trim('\n', '\r'))));
}
}
else
OutputResult(context, Utilities.GetWebServicesResult(-1, "Unkonw services"));
}
开发者ID:eleooo,项目名称:App,代码行数:60,代码来源:RestHandler.ashx.cs
示例10: ProcessRequest
public override void ProcessRequest(HttpContext context)
{
base.ProcessRequest(context);
context.Response.ContentType = "application/json";
string opr = context.Request["opr"] + "";
switch (opr)
{
case "Levellist"://列表
getLevelList(context);
break;
case "addLevel":
addLevel(context);
break;
case "editLevel":
editLevel(context);
break;
case "delLevel":
delLevel(context);
break;
case "getLevelRecord"://获取调价记录
getLevelRecord(context);
break;
}
}
开发者ID:Y-B-S,项目名称:OrderPrinnt,代码行数:25,代码来源:EvaluationLevelManager.ashx.cs
示例11:
void IHttpHandler.ProcessRequest(HttpContext httpContext)
{
_context = httpContext;
var path = _context.Request.Url.AbsolutePath;
var ext = (Path.GetExtension(path) ?? string.Empty).ToLower();
if (Contains.Config.Image.Exts.Contains(ext))
{
Util.ResponseImage(_context);
return;
}
var fileName = Path.GetFileNameWithoutExtension(path);
var db = path.Split('/')[2];
var stream = GridFsManager.Instance(db).Read(fileName);
var hash = _context.Request.Url.AbsoluteUri.Md5();
if (Util.IsCachedOnBrowser(_context, hash))
return;
var resp = _context.Response;
resp.AppendHeader("Vary", "Accept-Encoding");
resp.AppendHeader("Cache-Control", "max-age=604800");
resp.AppendHeader("Expires", DateTime.Now.AddYears(1).ToString("R"));
resp.AppendHeader("ETag", hash);
resp.ContentType = Contains.MiniType[ext];
resp.Charset = "utf-8";
stream.CopyTo(resp.OutputStream);
stream.Flush();
stream.Close();
resp.End();
}
开发者ID:shoy160,项目名称:Shoy.Common,代码行数:31,代码来源:GridFsHandler.cs
示例12: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
long uid = CY.Utility.Common.ConvertUtility.ConvertToLong(context.Request.QueryString["uid"], 0);
if (uid == 0)
{
context.Response.Write("{success:false,msg:'活动正在统计中....'}");
return;
}
CY.UME.Core.Business.Account account = CY.UME.Core.Business.Account.Load(uid);
if (account != null)
{
context.Response.Write("{success:true,n:'" + account.Name + "'}");
return;
}
else
{
context.Response.Write("{success:false,msg:'用户不存在'}");
return;
}
}
开发者ID:dalinhuang,项目名称:ume-v3,代码行数:25,代码来源:ShowAccountName.ashx.cs
示例13: ProcessRequest
public void ProcessRequest(HttpContext context)
{
string action = context.Request.Form["Action"];
context.Response.Clear();
context.Response.ContentType = "application/json";
try
{
switch (action)
{
#region 本月账单
case "currentMon":
TradeLsit(context, action);
break;
#endregion
#region 全部账单
case "allMon":
TradeLsit(context, action);
break;
#endregion
default:
break;
}
}
catch (Exception ex)
{
JsonObject json = new JsonObject();
json.Put(TAO_KEY_STATUS, TAO_STATUS_ERROR);
json.Put(TAO_KEY_DATA, ex);
context.Response.Write(json.ToString());
}
}
开发者ID:bookxiao,项目名称:orisoft,代码行数:32,代码来源:TradeDetailsHandle.cs
示例14: ProcessRequest
public void ProcessRequest(HttpContext context)
{
NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
int pageIndex = 1, pageSize = 10;
string orderStr = string.Empty, whereStr = string.Empty;
int pledgeApplyId = 0;
if (!string.IsNullOrEmpty(context.Request.QueryString["pid"]))
{
if (!int.TryParse(context.Request.QueryString["pid"], out pledgeApplyId))
pledgeApplyId = 0;
}
if (!string.IsNullOrEmpty(context.Request.QueryString["pagenum"]))
int.TryParse(context.Request.QueryString["pagenum"], out pageIndex);
pageIndex++;
if (!string.IsNullOrEmpty(context.Request.QueryString["pagesize"]))
int.TryParse(context.Request.QueryString["pagesize"], out pageSize);
if (!string.IsNullOrEmpty(context.Request.QueryString["sortdatafield"]) && !string.IsNullOrEmpty(context.Request.QueryString["sortorder"]))
orderStr = string.Format("{0} {1}", context.Request.QueryString["sortdatafield"].Trim(), context.Request.QueryString["sortorder"].Trim());
FinanceService.FinService service = new FinanceService.FinService();
string result = service.GetFinancingPledgeApplyStockDetailForHandList(pageIndex, 500, orderStr, pledgeApplyId);
context.Response.Write(result);
}
开发者ID:weiliji,项目名称:NFMT,代码行数:27,代码来源:FinancingPledgeApplyStockDetailForHandHandler.ashx.cs
示例15: ProcessRequest
public void ProcessRequest(HttpContext context) {
context.Response.ContentType = "text/xml";// the data is passed in XML format
var action = new DataAction(context.Request.Form);
var data = new SchedulerDataContext();
try {
var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), context.Request.Form);
switch (action.Type) {
case DataActionTypes.Insert: // Insert logic
data.Events.InsertOnSubmit(changedEvent);
break;
case DataActionTypes.Delete: // Delete logic
changedEvent = data.Events.SingleOrDefault(ev => ev.EventID == action.SourceId);
data.Events.DeleteOnSubmit(changedEvent);
break;
default:// "update" // Update logic
var updated = data.Events.SingleOrDefault(ev => ev.EventID == action.SourceId);
DHXEventsHelper.Update(updated, changedEvent, new List<string>() { "EventID" });
break;
}
data.SubmitChanges();
action.TargetId = changedEvent.EventID;
} catch (Exception) {
action.Type = DataActionTypes.Error;
}
context.Response.Write(new AjaxSaveResponse(action));
}
开发者ID:Wallruzz9114,项目名称:scheduler,代码行数:30,代码来源:Save.ashx.cs
示例16: SetEncoding
public static string SetEncoding(HttpContext context)
{
bool gzip, deflate;
string encoding = "none";
if (!string.IsNullOrEmpty(context.Request.ServerVariables["HTTP_ACCEPT_ENCODING"]))
{
string acceptedTypes = context.Request.ServerVariables["HTTP_ACCEPT_ENCODING"].ToLower();
gzip = acceptedTypes.Contains("gzip") || acceptedTypes.Contains("x-gzip") || acceptedTypes.Contains("*");
deflate = acceptedTypes.Contains("deflate");
}
else
gzip = deflate = false;
encoding = gzip ? "gzip" : (deflate ? "deflate" : "none");
if (context.Request.Browser.Browser == "IE")
{
if (context.Request.Browser.MajorVersion < 6)
encoding = "none";
else if (context.Request.Browser.MajorVersion == 6 &&
!string.IsNullOrEmpty(context.Request.ServerVariables["HTTP_USER_AGENT"]) &&
context.Request.ServerVariables["HTTP_USER_AGENT"].Contains("EV1"))
encoding = "none";
}
return encoding;
}
开发者ID:shoy160,项目名称:Shoy.Common,代码行数:26,代码来源:Util.cs
示例17: ProcessRequest
/// <summary>
///
/// </summary>
/// <param name="context"></param>
public void ProcessRequest(HttpContext context)
{
try
{
/// this is the empy response
string Html = string.Empty;
/// Dictionary Collection Native Encryption
Dictionary<string, string> Collection = cl.maia.bus.Utils.ContextForm.ProcessNativeEncryptedForm(context.Request.Form);
/// new expando object
string mercante = string.Empty;
/// foreach string for the value collection
foreach (KeyValuePair<string, string> kvp in Collection)
{
/// value for the parse id
if (kvp.Key == "__m")
{
mercante = kvp.Value;
}
}
/// json
string json = JsonConvert.SerializeObject(ClientLogics.ReadPromocionesPorMercante(int.Parse(mercante)));
/// context response
context.Response.Write(json);
}
catch(Exception ex)
{
/// context response as an error
context.Response.Write("{\"acknowledge\": {\"response\": \""+ex.ToString()+"\"}");
}
}
开发者ID:hgoycoolea,项目名称:insitu.platform,代码行数:34,代码来源:ReadPromocionesPorMercante.cs
示例18: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
if (context.Request["mode"] != null)
{
string mode = context.Request["mode"].ToString();
switch (mode)
{
case "inf":/*��ѯʵ����*/
InfoData(context);
break;
case "ins":/*����*/
SaveData(context);
break;
case "upd":/*��*/
SaveData(context);
break;
case "del":/*ɾ��*/
DeleteData(context);
break;
case "qrycode":/*���������ѯ*/
QueryDataCode(context, false);
break;
case "qrydate":/*�������ڲ�ѯ*/
QueryDataDate(context, false);
break;
}
}
}
开发者ID:aj-hc,项目名称:ZSSY,代码行数:29,代码来源:OPListForSpecimen_handler.ashx.cs
示例19: DisposeHandler
internal static void DisposeHandler(HttpContext context, IntPtr nativeRequestContext, RequestNotificationStatus status)
{
if (UnsafeIISMethods.MgdCanDisposeManagedContext(nativeRequestContext, status))
{
DisposeHandlerPrivate(context);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:PipelineRuntime.cs
示例20: Edit
public static ReturnObject Edit(HttpContext context, string name, string website = "", string phone = "", long? id = null)
{
Lib.Data.DrugCompany item = null;
if (id > 0)
item = new Lib.Data.DrugCompany(id);
else
item = new Lib.Data.DrugCompany();
item.Name = name;
item.Website = website;
item.Phone = phone;
item.Save();
return new ReturnObject()
{
Result = item,
Redirect = new ReturnRedirectObject()
{
Hash = "admin/drugs/companies/list"
},
Growl = new ReturnGrowlObject()
{
Type = "default",
Vars = new ReturnGrowlVarsObject()
{
text = "You have successfully saved this drug company.",
title = "Drug Company Saved"
}
}
};
}
开发者ID:REMSLogic,项目名称:REMSLogic,代码行数:31,代码来源:Company.cs
注:本文中的System.Web.HttpContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论