我正在尝试将elmah用于我的MVC应用程序,并且我已按照wiki上的步骤操作:http://code.google.com/p/elmah/wiki/MVC,但在尝试访问myapp/elmah时仍然如此.axd页面:
404 - 找不到文件或目录.
有人可以帮我吗?
OBS:我的IIS版本是7.5
如果有帮助我发布我的web.config的相关部分:
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
...
</connectionStrings>
<elmah>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>
<system.web>
...
<httpHandlers>
<remove verb="*" path="*.asmx" />
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, …Run Code Online (Sandbox Code Playgroud) 我想使用PHP下载URL的内容,即使HTTP响应代码是404. file_get_contents将出错,我无法使用Google找到答案.我怎样才能做到这一点?
如果我的网站发生错误,我会执行以下操作:
Server.Transfer("/error.aspx");
Run Code Online (Sandbox Code Playgroud)
那个页面有代码:
protected void Page_Load(object sender, EventArgs e)
{
...
Response.StatusCode = 404;
}
Run Code Online (Sandbox Code Playgroud)
如果我在localhost上工作,那么返回页面的404状态,页面显示"正确的错误描述".
一旦我向互联网发布了相同的代码,所有有错误的页面仍然会显示404状态代码,但是没有内容.相反,他们有标准的404错误消息:
404 - 找不到文件或目录.
如果"Response.StatusCode = 404"行被注释掉,那么提供了正确的页面,但它有200个状态代码.
问题:如何返回用户友好的错误页面,同时有404错误状态码?
欢迎任何想法!非常感谢提前!
PS ASP.NET 4.0
我在NGINX服务器上有一个站点主机,它曾经index.php在nginx站点配置中正常工作try_files.
但现在我要在其上添加一个博客,URL将在哪里www.foo.com/blog,我可以访问博客并使用index.php?p=.
但是,一旦我使用Nginx Helper的非常永久链接www.foo.com/blog/2013/07/bar,我就会得到404.
server {
# don't forget to tell on which port this server listens
listen 80;
# listen on the www host
server_name foo.com;
# and redirect to the non-www host (declared below)
return 301 $scheme://www.ultra-case.com$request_uri;
}
server {
# listen 80 default_server deferred; # for Linux
# listen 80 default_server accept_filter=httpready; # for FreeBSD
listen 80;
# The host name …Run Code Online (Sandbox Code Playgroud) 我正在使用$ routeProvider和$ locationProvider在单页面应用程序(SPA)中处理pushstate URLS,如下所示:
angular.module('pets', [])
.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider.when('/pet/:petId', {
controller: 'petController'
});
})
.controller('petController', function($scope, petService, $routeParams){
petService.get('/api/pets/' + $routeParams.petId).success(function(data) {
$scope.pet = data;
});
});
Run Code Online (Sandbox Code Playgroud)
URL用于从服务器提取可能存在或不存在的内容.
如果这是一个普通的多页面网站,对丢失内容的请求将触发来自服务器的404标头响应,并且对移动内容的请求将触发301.这将提醒谷歌丢失或移动的内容.
比方说,我点击了这样一个URL:
http://example.com/pet/123456
并且说数据库中没有这样的宠物,我的SPA如何在该内容上返回404.
如果没有这个,是否有其他方法可以正确地提醒用户或搜索引擎所请求的URL不存在?还有其他一些我不考虑的解决方案吗?
seo http-status-code-404 pushstate angularjs angular-routing
在Laravel 4我曾经能够简单地打电话
App::abort(404)
Run Code Online (Sandbox Code Playgroud)
有没有等价的Laravel 5?
在撰写本文时,似乎有令人惊讶的有限信息.我已经找到了关于如何捕获NotFoundHttpExceptions的讨论,但这不是我想要的,因为我的routes.php文件已经处理了url结构.为了给出更多背景知识,这里是我想要做的简化版本:
routes.php文件:
Route::get('/info/{page}', array('as' => 'info', 'uses' => 'Primary@infoPage'));
Run Code Online (Sandbox Code Playgroud)
Primary.php(控制器)
public function infoPage($page){
$pageData = DB::table('pages')->where('url_title', $page)->first();
if(!empty($pageData)){
// great, there's a corresponding row in the database for this page, go ahead and do stuff...
}else {
// This page doesn't exist, please abort with a 404 error... but how?
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个webapp需要处理URI以查找数据库中是否存在页面.我没有问题使用.htaccess将URI指向应用程序:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php?p=$1 [NC]
Run Code Online (Sandbox Code Playgroud)
我的问题是,如果页面不存在,我不想使用用PHP编写的自定义404处理程序,我想显示默认的Apache 404页面.当确定页面不存在时,有没有办法让PHP将执行权交还给Apache?
嗨,我正在尝试为应用程序引擎上的404未找到错误设置静态错误页面.
根据https://developers.google.com/appengine/docs/java/config/webxml#Error_Handlers:它说404无法自定义.
根据:https: //developers.google.com/appengine/docs/java/config/appconfig#Custom_Error_Responses它似乎也不支持404.
但是,https://groups.google.com/forum/?fromgroups =#!topic/google-appengine-java/3C-pY5ta2HQ似乎建议可以自定义404错误页面.我现在很困惑.
我刚刚结束了一个大学项目,我不确定我是否一直盯着我的电脑太长时间并且遗漏了一些显而易见的东西,但是当我尝试将用户注销时,我得到了404而不是找到URL /帐户/ LogOff.
我有一个导航栏,显示登录/注销,具体取决于用户是,登录还是注销:
<div class="nav-collapse collapse">
<ul class="nav pull-right">
<li class="dropdown" id="dropdown-login-div">
@if (!Request.IsAuthenticated)
{
<a class="dropdown-toggle" href="#" data-toggle="dropdown">Sign In <strong class="caret"></strong></a>
}
else
{
@Html.ActionLink("Log Off", "LogOff", "Account")
}
<div class="dropdown-menu" id="dropdown-login">
@Html.Partial("~/Views/Account/_LoginPartial.cshtml", new ViewDataDictionary<LetLord.Models.LoginModel>())
</div>
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
在我的帐户控制器中,Internet模板附带的默认LogOff操作:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
WebSecurity.Logout();
return View("Index");
}
Run Code Online (Sandbox Code Playgroud)
有人能告诉我为什么会发生这种情况 - 在我将笔记本电脑靠在墙上之前.干杯.
我在Redhat Open shift上主持了一个应用程序.我没有改变任何东西,但它开始重定向到https://www.plovist.com/app并抛出404错误.任何人都可以帮我解决这个问题吗?