本文整理汇总了C#中WebContext类的典型用法代码示例。如果您正苦于以下问题:C# WebContext类的具体用法?C# WebContext怎么用?C# WebContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebContext类属于命名空间,在下文中一共展示了WebContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: doProcessRequest
private void doProcessRequest(HttpContext httpcontext)
{
PatcherInfo.instance.CheckDBUpToDate();
Uri current = httpcontext.Request.Url;
if(!current.Host.EndsWith(Config.instance.BaseHost)) {
throw new FLocalException("Wrong host: " + current.Host + " (expected *" + Config.instance.BaseHost + ")");
}
if(Config.instance.forceHttps && !httpcontext.Request.IsSecureConnection) {
throw new FLocalException("Only HTTPS connections are allowed");
}
Uri referer = httpcontext.Request.UrlReferrer;
if(referer != null && referer.PathAndQuery.StartsWith("/static") && !httpcontext.Request.Path.StartsWith("/static")) {
throw new HttpException(403, "You have come from the static page '" + referer + "'");
}
WebContext context = new WebContext(httpcontext);
try {
ISpecificHandler handler = HandlersFactory.getHandler(context);
handler.Handle(context);
} catch(WrongUrlException) {
(new handlers.WrongUrlHandler()).Handle(context);
}
}
示例2: LoadDisplay
public void LoadDisplay(File file)
{
IWebContext _webcontext = new WebContext();
UserSession _usersession = new UserSession();
if (_usersession.CurrentUser != null)
{
if (_webcontext.AccountID > 0 && _usersession.CurrentUser.AccountID != _webcontext.AccountID)
{
if (file.IsPublicResource == true)
{
Image1.ImageUrl = "~/Photo/ProfileAvatar.aspx?FileID=" + file.FileID;
Name.Text = file.FileName;
Date.Text = file.CreateDate.ToString();
Desc.Text = "File Share by"+ file.AccountID;
FileID.Text = file.FileID.ToString();
Ispublic.Checked = true;
LoadFriend();
}
else div1.Visible = false;
}
else
{
Image1.ImageUrl = "~/Photo/ProfileAvatar.aspx?FileID=" + file.FileID;
Name.Text = file.FileName;
Date.Text = file.CreateDate.ToString();
Desc.Text = "File Share by" + file.AccountID;
FileID.Text = file.FileID.ToString();
Ispublic.Checked = file.IsPublicResource;
LoadFriend();
}
}
}
示例3: Run
public void Run(IHostServer server, WebContext context, string callbackEndPoint, CancellationToken cancel) {
var ctx = RequestParameters.Create(context);
var login = ctx.Get("login");
var role = ctx.Get("role");
var exact = ctx.Get("exact").ToBool();
if (string.IsNullOrWhiteSpace(role)) {
context.Finish("{\"error\":\"emptyrole\"}", status: 500);
return;
}
if (string.IsNullOrWhiteSpace(login)) {
login = context.User.Identity.Name;
}
var result = false;
if (login != context.User.Identity.Name) {
if (!Roles.IsInRole(context.User.Identity, SecurityConst.ROLE_ADMIN)) {
context.Finish("{\"error\":\"adminrequire\"}", status: 500);
return;
}
result = Roles.IsInRole(login, role, exact);
}
else {
result = Roles.IsInRole(context.User.Identity, role, exact);
}
context.Finish(result.ToString().ToLowerInvariant());
}
示例4: ListInstrumentsJSON
private static void ListInstrumentsJSON(WebContext context, Song s)
{
JSONWriter jw = new JSONWriter();
jw.Array();
for (int k = 0; k < s.Instruments.Count; k++)
{
Instrument ins = s.Instruments[k];
jw.Class();
jw.Field("id", ins.ID);
jw.Field("name", ins.Name);
jw.Field("device", ins.MidiDevice);
jw.Field("channel", ins.MidiChannel);
jw.Field("patch", ins.MidiPatch);
jw.Field("type", ins.Type);
jw.End();
}
jw.End();
context.Response.Write("g_Instruments = ");
context.Response.Write(jw.ToString(JSONFormatting.Pretty));
context.Response.Write(";\n");
}
示例5: Login
public ActionResult Login(string username, string tel)
{
bool Success = false;
userinfo currentModel = Daxu.BLL.userinfoBll.GetEntity<userinfo>(new SearchEntityList()
{
ModelEqual = "userinfo",
TellEqual = tel,
userNameEqual = username
}, null);
if (currentModel != null)
{
WebContext webcontex = new WebContext(HttpContext);
webcontex.UserLogin(username, new UserData()
{
UserID = currentModel.id,
UserName = currentModel.name,
FullName = currentModel.name
});
return Json(new ResultMessage() { Success = true, Message = "正在跳转..." });
}
else
{
return Json(new ResultMessage() { Success = false, Message = "用户信息出错!" });
}
}
示例6: ShowFriendPresenter
public ShowFriendPresenter()
{
_friendRepository = new SPKTCore.Core.DataAccess.Impl.FriendRepository();
_userSession = new SPKTCore.Core.Impl.UserSession();
_friendService = new FriendService();
_ac = new SPKTCore.Core.DataAccess.Impl.AccountRepository();
_webcontext = new WebContext();
}
示例7: AuthorizeRequest
static void AuthorizeRequest(object sender, EventArgs e)
{
var context = new WebContext(HttpContext.Current);
foreach (var pipe in Pipeline)
{
pipe.Before(context);
}
}
示例8: Login
public bool Login(string Username, string Password, bool rememberMe, out String returnMessage)
{
if (rememberMe == false)
return Login(Username, Password,out returnMessage);
IWebContext webContext = new WebContext();
webContext.SaveLoginInfoToCookie(Username, Password);
return Login(Username, Password, out returnMessage);
}
示例9: UserLogin
//--------------------登录、注销相关方法------------------------------------------------
/// <summary>
/// 用户登录
/// </summary>
/// <param name="userName"></param>
/// <param name="context"></param>
public void UserLogin( String userName, HttpContext context )
{
User user = getUserByName( userName );
if (user == null) throw new NullReferenceException( "试图登录的用户不存在,用户名=" + user.Name );
WebContext webContext = new WebContext( context );
// 注意:传入的Id和wojilu的ID是不同步的
webContext.UserLogin( user.Id, user.Name, wojilu.Common.LoginTime.OneMonth );
}
示例10: App
/// <summary>
/// Creates a new <see cref="App"/> instance.
/// </summary>
public App() {
InitializeComponent();
// Create a WebContext and add it to the ApplicationLifetimeObjects
// collection. This will then be available as WebContext.Current.
WebContext webContext = new WebContext();
webContext.Authentication = new FormsAuthentication();
//webContext.Authentication = new WindowsAuthentication();
this.ApplicationLifetimeObjects.Add(webContext);
}
示例11: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
_redirector = new Redirector();
_usersession = new UserSession();
_webcontext=new WebContext();
_fi=new FriendInvitationRepository();
_ac = new AccountRepository();
_mr = new MessageRecipientRepository();
_f = new FriendService();
Account acid;
if (_usersession.CurrentUser != null)
{
if (_webcontext.AccountID != _usersession.CurrentUser.AccountID && _webcontext.AccountID != 0)
{
acid = _ac.GetAccountByID(_webcontext.AccountID);
lblProfileName.Text = acid.UserName;
lb_ban.Text = " ( " + _f.SearchFriend(acid).Count.ToString() + " )";
testImage.Src = "~/Image/ProfileAvatar.aspx?AccountID=" + acid.AccountID;
AccordionPane1.Visible = false;
AccordionPane3.Visible = false;
id = acid.AccountID;
lbtnChangeAvatar.Visible = false;
}
else
{
lblProfileName.Text = _usersession.CurrentUser.UserName;
lb_ban.Text = " ( " + _f.SearchFriend(_usersession.CurrentUser).Count.ToString() + " )";
testImage.Src = "~/Image/ProfileAvatar.aspx?AccountID=" + _usersession.CurrentUser.AccountID;
AccordionPane1.Visible = true;
AccordionPane3.Visible = true;
lb_invite.Text = " ( " + _fi.FriendInv(_usersession.CurrentUser).Count.ToString() + " )";
id = _usersession.CurrentUser.AccountID;
lb_message.Text = " ( 0 ) ";
lbtnChangeAvatar.Visible = true;
//lb_message.Text = " ( " + _mr.getMessageRecipientByAccountID(_usersession.CurrentUser.AccountID).Count.ToString() + " ) ";
}
}
else
{
if (_webcontext.AccountID > 0)
{
acid = _ac.GetAccountByID(_webcontext.AccountID);
lblProfileName.Text = acid.UserName;
testImage.Src = "~/Image/ProfileAvatar.aspx?AccountID=" + acid.AccountID;
AccordionPane1.Visible = false;
AccordionPane3.Visible = false;
id = acid.AccountID;
lbtnChangeAvatar.Visible = false;
}
else
_redirector.GoToAccountLoginPage();
}
}
示例12: App
/// <summary>
/// Создает новый экземпляр класса <see cref="App"/>.
/// </summary>
public App()
{
InitializeComponent();
// Создание объекта WebContext и добавление его в коллекцию ApplicationLifetimeObjects.
// После этого он будет доступен как WebContext.Current.
WebContext webContext = new WebContext();
webContext.Authentication = new FormsAuthentication();
//webContext.Authentication = new WindowsAuthentication();
this.ApplicationLifetimeObjects.Add(webContext);
}
示例13: App
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
WebContext webContext = new WebContext();
this.ApplicationLifetimeObjects.Add(webContext);
InitializeComponent();
}
示例14: CreateInstance
/// <summary>
/// Creates the web context instance.
/// </summary>
internal static void CreateInstance()
{
lock (_lock)
{
if (_instance != null)
throw new InvalidOperationException("WebContext instance already exists.");
_instance = new WebContext();
_instance._channelFactory = new ChannelFactory<ITestHostService>(
new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/testhost"));
}
}
示例15: App
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
WebContext context = new WebContext();
context.Authentication = new FormsAuthentication();
this.ApplicationLifetimeObjects.Add(context);
}