• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# WebContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WebContext的典型用法代码示例。如果您正苦于以下问题:C# WebContext类的具体用法?C# WebContext怎么用?C# WebContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WebContext类属于命名空间,在下文中一共展示了WebContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
            }
        }
开发者ID:penartur,项目名称:FLocal,代码行数:25,代码来源:MainHandler.cs


示例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();
         }
     }
 }
开发者ID:SPKT,项目名称:MHX2,代码行数:32,代码来源:ShareFileItem.ascx.cs


示例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());
 }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:25,代码来源:IsInRoleHandler.cs


示例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");
        }
开发者ID:possan,项目名称:randomjunk,代码行数:25,代码来源:WebServerInterface.cs


示例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 = "用户信息出错!" });

            }
        }
开发者ID:dayuhan,项目名称:NETWORK,代码行数:29,代码来源:MembersController.cs


示例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();
 }
开发者ID:SPKT,项目名称:MHX2,代码行数:8,代码来源:ShowFriendPresenter.cs


示例7: AuthorizeRequest

 static void AuthorizeRequest(object sender, EventArgs e)
 {
     var context = new WebContext(HttpContext.Current);
     foreach (var pipe in Pipeline)
     {
         pipe.Before(context);
     }
 }
开发者ID:ProCoSys,项目名称:Bifrost,代码行数:8,代码来源:HttpModule.cs


示例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);
 }
开发者ID:SPKT,项目名称:MangXaHoi,代码行数:8,代码来源:AccountService.cs


示例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 );
        }
开发者ID:Boshin,项目名称:wojilu,代码行数:15,代码来源:OpenService.cs


示例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);
        }
开发者ID:slieser,项目名称:sandbox,代码行数:13,代码来源:App.xaml.cs


示例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();

            }
        }
开发者ID:SPKT,项目名称:MHX2,代码行数:55,代码来源:LEFT_MENU.ascx.cs


示例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);
        }
开发者ID:Ratatui,项目名称:DonorBank,代码行数:14,代码来源:App.xaml.cs


示例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();
        }
开发者ID:tdellenbach,项目名称:inte_silvermini,代码行数:11,代码来源:App.xaml.cs


示例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"));
            }
        }
开发者ID:JimmyJune,项目名称:blade,代码行数:15,代码来源:WebContext.cs


示例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);
        }
开发者ID:ynosa,项目名称:KanbanBoard,代码行数:12,代码来源:App.xaml.cs


示例16: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     //file1.Visible = false;
     _usersession = new UserSession();
     _webcontext = new WebContext();
     _for = new FolderRepository();
     re = new Redirector();
     if (_usersession.CurrentUser != null)
     {
        countA.Text=(_for.GetFoldersByAccountID1(_usersession.CurrentUser.AccountID)).Count.ToString();
       // pn.Height = 200 * (int.Parse(countA.Text));
     }
 }
开发者ID:SPKT,项目名称:MHX2,代码行数:13,代码来源:ManagePhoto.aspx.cs


示例17: App

        /// <summary>
        /// Creates a new <see cref="App"/> instance.
        /// </summary>
        public App()
        {
            InitializeComponent();

            _busyIndicator = new BusyIndicator();
            _busyIndicator.BusyContent = "User Authenticating, Please Wait...";
            // 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);
        }
开发者ID:talywy,项目名称:AccountBook,代码行数:16,代码来源:App.xaml.cs


示例18: GetResult

 protected override HandlerResult GetResult(IHostServer server, WebContext context, string callbackEndPoint, CancellationToken cancel) {
     var result = UserProcessor.DefineUser(context);
     var param = RequestParameters.Create(context);
     return new HandlerResult {
         Result = result,
         Data = new{
             result,
             call = new {
                 q = param.Query,
                 j = param.Json.jsonify()
             }
         }
     };
 }
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:14,代码来源:DefineUserHandler.cs


示例19: App

        public App()
        {
            this.Startup += this.Application_Startup;
            this.Exit += this.Application_Exit;
            this.UnhandledException += this.Application_UnhandledException;

            InitializeComponent();

            // 初期化
            var webContext = new WebContext();
            webContext.Authentication = new FormsAuthentication();
            this.ApplicationLifetimeObjects.Add(webContext);
            MVVMRxSampleApplication.Initialize(webContext);
        }
开发者ID:runceel,项目名称:MVVMRxSample,代码行数:14,代码来源:App.xaml.cs


示例20: 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);

            client = new Server.ServiceTcpClient();
            client.Endpoint.Behaviors.Add(new CustomHeaders.ConsumerEndpointBehavior());

        }
开发者ID:jpsfs,项目名称:feup-tdin-wcf_silverlight,代码行数:18,代码来源:App.xaml.cs



注:本文中的WebContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WebControl类代码示例发布时间:2022-05-24
下一篇:
C# WebClient类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap