在本文中,我们将带你了解如果我使用OWINStartup.cs类并将所有配置移到那里,我是否需要Global.asax.cs文件?在这篇文章中,同时我们还将给您一些技巧,以帮助您实现更有效的$GLOB
在本文中,我们将带你了解如果我使用 OWIN Startup.cs 类并将所有配置移到那里,我是否需要 Global.asax.cs 文件?在这篇文章中,同时我们还将给您一些技巧,以帮助您实现更有效的$GLOBALS ["HTTP_RAW_POST_DATA"] 取不到值如何排除 global times jeunesseglobal global marke、android – 如果我使用Picasso或Glide或Volley检索它,我是否需要提供不同大小的图像?、asp.net – App_Code中的类无法通过Global.asax.cs访问、asp.net – Global.asax.cs事件在网站发布后未触发。
本文目录一览:- 如果我使用 OWIN Startup.cs 类并将所有配置移到那里,我是否需要 Global.asax.cs 文件?
- $GLOBALS ["HTTP_RAW_POST_DATA"] 取不到值如何排除 global times jeunesseglobal global marke
- android – 如果我使用Picasso或Glide或Volley检索它,我是否需要提供不同大小的图像?
- asp.net – App_Code中的类无法通过Global.asax.cs访问
- asp.net – Global.asax.cs事件在网站发布后未触发
如果我使用 OWIN Startup.cs 类并将所有配置移到那里,我是否需要 Global.asax.cs 文件?
例如,在一个全新的 ASP.NET MVC 5 应用程序中,使用 MVC with Individual Accounts
模板制作,如果我删除Global.asax.cs
该类并将其配置代码移动到Startup.cs
Configuration()
如下方法,那么缺点是什么?
public partial class Startup{ public void Configuration(IAppBuilder app) { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); ConfigureAuth(app); }}
对我来说好处是,当将 ASP.NET 4 应用程序升级到 ASP.NET 5 并使用现在必须在 Startup.cs
类中配置的部分时,我没有在两个看起来相关的不同类中进行依赖注入和其他配置启动和配置。
答案1
小编典典Startup.Configuration 的调用比 Application_Start 稍晚一些,但我认为在大多数情况下差异并不重要。
我相信我们在 Global.asax 中保留其他代码的主要原因是:
- 与以前版本的 MVC 保持一致。(这是目前每个人都希望找到此代码的地方。)
- 能够添加其他事件处理程序。在 Global.asax 中,您可以处理其他方法,例如 Session_Start 和 Application_Error。
- 在各种身份验证场景中的正确性。只有在 bin 目录中有 Microsoft.Owin.Host.SystemWeb.dll 时才会调用 Startup.Configuration 方法。如果您删除此 DLL,它将默默地停止调用 Startup.Configuration,这可能很难理解。
我认为第三个原因是我们默认没有采用这种方法的最重要的原因,因为某些场景不包括拥有这个
DLL,并且能够更改身份验证方法而不会使无关代码的位置无效(比如路由注册)被放置。
但是,如果这些原因都不适用于您的场景,我认为您可以使用这种方法。
$GLOBALS ["HTTP_RAW_POST_DATA"] 取不到值如何排除 global times jeunesseglobal global marke
1.用file_get_contents(''php://input'')获取数据。如果获取不到,则可能是数据传输错误,对请求进行捉包,分析数据。
2.如果file_get_contents(''php://input'')有数据。则查看php.ini配置文件。
找到如下,如果没开启则开启
always_populate_raw_post_data = On
以上就介绍了$GLOBALS ["HTTP_RAW_POST_DATA"] 取不到值如何排除,包括了global,http方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
android – 如果我使用Picasso或Glide或Volley检索它,我是否需要提供不同大小的图像?
注意:如果我提供不同大小或密度的图像,我不会检索所有图像.我只是检索所有图像网址,只需下载一次.这种方式更好,还是提供一个原始图像网址并检索它并将其重新调整到合适的大小更好?
解决方法
您需要在服务器端只有小图像,这将减少内存使用,网络使用和显示图片的时间.
另一种情况是大图像.
例如:
这里显示音乐专辑和图像必须具有高分辨率.
如果您的服务器上有两种类型的图像,一个小图像和一个大图像,并且您可以根据情况接收图像,那就更好了.
不要担心硬盘的大小,这将使ImageLoaders控制自己.图像大小对内存使用和网络使用的影响.
asp.net – App_Code中的类无法通过Global.asax.cs访问
namespace Site { public class MyClass { public MyClass() { } } }
这是我的Global.asax.cs
namespace Site { public class Global : System.Web.HttpApplication { protected void Application_Start(object sender,EventArgs e) { *MyClass myClass = new MyClass();* } } }
错误在:MyClass myClass = new MyClass();
不能找到类型或命名空间名称“MyClass”(您是否缺少using指令或程序集引用?)
我在这里缺少什么?
解决方法
asp.net – Global.asax.cs事件在网站发布后未触发
我在VS 2010(.Net 4.0框架,C#)中有一个WebSite,它在根目录中有一个Global.asax文件,在App_Code文件夹中有一个Global.asax.cs文件. (请注意,这是一个WebSite,而不是Web应用程序).从我的本地开发机器运行此WebSite时,一切都按预期运行 – 更具体地说,Global.asax.cs文件中的Session_Start事件在每个会话开始时触发并运行一些代码以获取用户的登录凭据,这将确定它们的内容允许根据应用程序的安全级别查看/编辑应用程序.
但是,一旦我将此WebSite发布到Windows 2003 R2服务器上,Global.asax.cs文件中的所有事件都不会触发. (只有Session_Start事件中需要代码,但我也将代码放在Application_Start中,只是为了查看它是否会触发 – 它没有).
这是Global.asax代码:
<%@ Application CodeBehind="~\App_Code\Global.asax.cs" Inherits="Global" Language="C#" %>
这是Global.asax.cs代码:
using System; using System.Collections.Generic; using System.Linq; using System.Web; /// <summary> /// Summary description for Global /// </summary> public partial class Global : System.Web.HttpApplication { public Global() { // Todo: Add constructor logic here } protected void Application_Start(object sender,EventArgs e) { // Code that runs on application startup } protected void Application_End(object sender,EventArgs e) { // Code that runs on application shutdown } protected void Application_Error(object sender,EventArgs e) { // Code that runs when an unhandled error occurs } void Session_Start(object sender,EventArgs e) { try { Session["SessionSink"] = new SessionSink(); this.GetUserName(); } catch (Exception ex) { string msg = "An error occurred in Global.asax::Session_Start"; ExceptionWriter ew = new ExceptionWriter(); ew.LogError(msg,ex); } } void Session_End(object sender,EventArgs e) { // Code that runs when a session ends. } }
基于我读过的其他答案/讨论的一些注释:一旦发布,precompiledApp.config就会出现在网站的文件夹中.此外,App_global.asax.compiled和App_global.asax.dll出现在bin文件夹中.
任何人都知道问题可能是什么?为什么这可以从我的本地机器上运行,但是一旦它发布到服务器上就不行?是否存在我缺少的IIS设置?
这是我第一次使用asp.net“网站”,所以任何帮助将不胜感激.谢谢.
解决方法
<%@ Application Language="C#" Inherits="System.Web.HttpApplication" %> <script runat="server"> public override void Init() { base.Init(); var module = (SessionStateModule)Modules["Session"]; module.Start += new EventHandler((sender,args) => { // create session sink here }); } </script>
我们今天的关于如果我使用 OWIN Startup.cs 类并将所有配置移到那里,我是否需要 Global.asax.cs 文件?的分享已经告一段落,感谢您的关注,如果您想了解更多关于$GLOBALS ["HTTP_RAW_POST_DATA"] 取不到值如何排除 global times jeunesseglobal global marke、android – 如果我使用Picasso或Glide或Volley检索它,我是否需要提供不同大小的图像?、asp.net – App_Code中的类无法通过Global.asax.cs访问、asp.net – Global.asax.cs事件在网站发布后未触发的相关信息,请在本站查询。
本文标签: