我正在开发一个MVC3基础网站,我正在寻找一个处理错误的解决方案,并为每种错误渲染自定义视图.因此,假设我有一个"错误"控制器,其主要操作是"索引"(通用错误页面),并且此控制器将针对用户可能出现的错误(如"Handle500"或"HandleActionNotFound")执行更多操作.
因此,网站上可能发生的每个错误都可能由此"错误"控制器处理(例如:"Controller"或"Action"未找到,500,404,dbException等).
我使用Sitemap文件来定义网站路径(而不是路由).
这个问题已经回答了,这是对Gweebz的回复
我的最终applicaiton_error方法如下:
protected void Application_Error() {
//while my project is running in debug mode
if (HttpContext.Current.IsDebuggingEnabled && WebConfigurationManager.AppSettings["EnableCustomErrorPage"].Equals("false"))
{
Log.Logger.Error("unhandled exception: ", Server.GetLastError());
}
else
{
try
{
var exception = Server.GetLastError();
Log.Logger.Error("unhandled exception: ", exception);
Response.Clear();
Server.ClearError();
var routeData = new RouteData();
routeData.Values["controller"] = "Errors";
routeData.Values["action"] = "General";
routeData.Values["exception"] = exception;
IController errorsController = new ErrorsController();
var rc = new RequestContext(new HttpContextWrapper(Context), routeData);
errorsController.Execute(rc);
}
catch (Exception e)
{
//if Error controller failed for same reason, …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个像样的图像精灵生成器.我试过http://spritegen.website-performance.org/,但它不够"聪明",不足以处理多个图像尺寸,并将它们与图像之间的空白空间合并.
有什么建议???
我正在尝试从Windows容器运行旧版ASP.Net(.Net 4.7.1)应用程序。要求之一是将系统区域性,语言环境和位置设置为en-GB。我不允许触摸代码,如果绝对需要,只能触摸web.config。
考虑以下方法:
我的基本映像的Dockerfile是:
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2
ARG site_root=.
WORKDIR /scripts
COPY scripts/ .
RUN powershell -f install-certificates.ps1
RUN powershell C:/Windows/System32/inetsrv/appcmd.exe set config /commit:WEBROOT /section:globalization /culture:en-GB
RUN powershell C:/Windows/System32/inetsrv/appcmd.exe set config /commit:WEBROOT /section:globalization /uiCulture:en-GB
RUN powershell Set-Culture en-GB
RUN powershell Set-WinSystemLocale en-GB
RUN powershell Set-WinHomeLocation -GeoId 242
RUN powershell Set-WinUserLanguageList en-GB -Force
Run Code Online (Sandbox Code Playgroud)
然后构建并运行容器。
docker build -t tmpaspnet .
docker run -it --name tmpcontainer --entrypoint powershell tmpaspnet
# inside the container
Restart-Computer
# container will exit, wait …Run Code Online (Sandbox Code Playgroud) 我使用InnerActive作为我的Windows Phone应用程序的默认广告提供.我从2013年6月开始使用它,在年终分析中,我发现InnerActive广告是我应用程序崩溃的主要来源.最糟糕的是,它的代码不是我没有任何控制权.我已经针对请求Inneractive Ads的每个操作放置了"try catch".
有谁知道如何解决这个问题?
我用来请求广告的代码在哪里:
private void LoadInnerActiveAds()
{
try
{
if (DeviceNetworkInformation.IsNetworkAvailable)
{
// Watch location
if (_allowAdLocationTracker)
{
IaLocationClass iaLocation = new IaLocationClass();
iaLocation.Done += new EventHandler<IaLocationEventArgs>(InnerActiveLocation_Done);
iaLocation.StartWatchLocation();
}
optionalParams = new Dictionary<InneractiveAd.IaOptionalParams, string>();
//optionalParams.Add(InneractiveAd.IaOptionalParams.Key_Gender, "m");
optionalParams.Add(InneractiveAd.IaOptionalParams.Key_Ad_Alignment, InneractiveAd.IaAdAlignment.CENTER.ToString());
optionalParams.Add(InneractiveAd.IaOptionalParams.Key_OptionalAdWidth, "480");
optionalParams.Add(InneractiveAd.IaOptionalParams.Key_OptionalAdHeight, "80");
}
//Show Add Banner. Remarks: pay attention to use Application Id from NAX
//naxAd.Childred.Count()==0 => just to add one banner control on a page. Without this, code would add as many banners as you navigate …Run Code Online (Sandbox Code Playgroud) 我正在使用HTML5构建Windows 8应用程序,我正试图将我的应用程序菜单放在屏幕中间.我知道有新的CSS3来应用这个功能,通过使用灵活的盒子,但我无法重新创建它.这是我的HTML
<body>
<div id="playControl">
<button>Back</button>
<button>Play</button>
<button>Forward</button>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
这里有一些信息,但看起来不正常(我猜他们改变了属性名称)
谢谢