标签: http-status-code-404

ASP.NET MVC 5 - (HTTP错误404.0 - 未找到)具有长的不存在的URL

我在Microsoft Visual Studio Express 2013 for Web中创建了一个新项目.它是一个ASP.NET MVC 5 - .NET Framework 4.5项目.

我想处理(无法找到资源):

没有找到您要查的资源

我确实使用下面的代码处理它.

如果我执行类似(/ Home/kddiede/ddiij)或(/ djdied/djie/djs)的操作,此代码将起作用,这将导致显示我的自定义错误页面.

但是,当我尝试执行类似(/ Home/kddiede/ddiij/dfd/sdfds/dsf/dsfds/fd)或任何长的不存在的URL时,它会向我显示:

HTTP错误404.0  - 未找到

代码来自:http://www.codeproject.com/Articles/635324/Another-set-of-ASP-NET-MVC-4-tips

技巧16:自定义错误屏幕

错误页面位于/View/Shared/Error.cshtml中

Web.config文件

<system.web>
<customErrors mode="RemoteOnly" />
</system.web>
Run Code Online (Sandbox Code Playgroud)

Global.asax中

protected void Application_EndRequest(Object sender, EventArgs e)
{
    ErrorConfig.Handle(Context);
}
Run Code Online (Sandbox Code Playgroud)

ErrorConfig类

public class ErrorConfig
{
  public static void Handle(HttpContext context)
  {
    switch (context.Response.StatusCode)
    {
      //Not authorized
      case 401:
        Show(context, 401);
        break;

      //Not found
      case 404:
        Show(context, 404);
        break;
    }
  }

  static void Show(HttpContext context, Int32 code)
  {
    context.Response.Clear(); …
Run Code Online (Sandbox Code Playgroud)

url asp.net-mvc asp.net-routing http-status-code-404

9
推荐指数
2
解决办法
3万
查看次数

nginx - 404找不到永久链接的页面

我和我的朋友有一个网站(http://www.ferfereh.ir - 抱歉不是英文)一年.我们一直在使用安装了wordpress的Linux Apache主机.现在,我们所有的帖子(有永久链接结构= /%category%/%postname%.html)突然爆发并说:

404未找到

nginx的

也许我们的主机提供商安装了​​NginX.我不知道Nginx到底是什么,但我在某处读到它与.htaccess配置有一些冲突,这使得我们永久链接,是的.

我该怎么办?

非常感谢

wordpress .htaccess permalinks nginx http-status-code-404

8
推荐指数
1
解决办法
1万
查看次数

什么时候404不是404?

我正在使用下面的jQuery调用来加载位于同一服务器上的.php文件.

但是,使用Chrome的javascript控制台,它在我试图加载的php文件上报告"404 not found".虽然,我可以直接加载文件,只需在控制台中单击该文件即可.

此外,我可以直接从它报告404(未找到)的javascript控制台复制文件的URL,打开一个新选项卡,将其粘贴到地址栏中,然后点击脚本,没有问题.

这是jQuery get方法特有的吗?什么可能导致get方法中的页面404,但直接调用时执行正常?

$('.colorReset').click
    (
        function() 
        {
        var myImage = $('#theme :selected').text();
        $.get('<?php echo get_bloginfo('template_directory') ?>/colorReset.php', {theme: myImage, spot: '1'}, function(data){doColor('#theme_header_color', data);});
        }
    );

    //script never gets to the doColor function, due to the apparent 404 on colorReset.php
function doColor(el, color)
    {
    $(el).val(color).trigger('keyup');
    $(el).attr('value', color);
    $(el).val(color);
}
Run Code Online (Sandbox Code Playgroud)

这是javascript控制台结果

我可以使用控制台报告为404的相同URL直接调用该文件

标题报告

这是源文件colorReset.php,由get ...调用.

<?php
require_once('../../../wp-blog-header.php');

add_action( 'admin_init', 'check_user' );

function check_user()
    {
    if (!is_user_logged_in()){
        die("You Must Be Logged In to Access This");
    }
    if( ! current_user_can('edit_files')) {
        die("Oops sorry you …
Run Code Online (Sandbox Code Playgroud)

php apache jquery http-status-code-404

8
推荐指数
2
解决办法
2440
查看次数

如何检测php curl中的URL Not Found错误?

如何使用php curl检测此错误?即使URL不存在,curl也会返回成功.

Not Found
The requested URL /foo/index.php/items/edit was not found on this server.
Run Code Online (Sandbox Code Playgroud)

我的代码

$post_fields = array('info' => json_encode($fields));
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_POST,count($post_fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS,$post_fields);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLINFO_CONTENT_TYPE,'application/x-www-form-urlencoded charset=utf-8');

    $result = curl_exec($ch);
    echo $result;

    if(curl_error($ch)){
        $result = curl_error($ch);
        curl_close($ch);
        return $result;
    }else{
        curl_close($ch);
        return json_decode($result,true);

    }
Run Code Online (Sandbox Code Playgroud)

php url curl http-status-code-404 php-curl

8
推荐指数
1
解决办法
9529
查看次数

Kendo MVC没有显示Sprites.PNG 404错误

Vs'12互联网应用模板+ KendoUI - MVC4,EF Code First

  • 跟着KendoDocumentation
  • 使用Kahanu的Awesome帖子调整
  • 一切都很好,所以我<compilation debug="false" targetFramework="4.5">从真实变为虚假
  • Kendo UI停止发现Spites.png(由Kendo提供)
  • 看了,找到了这个(没解决我的问题):stackOverflow1
  • 检查并重新检查步骤1-2,去服务器上寻找Sprites.png,它存在..但是在一些Kendo的子模型中不在下面的目录中?/

我在哪里重新编写代码并让它在实际位置查找精灵而不是这个?:获取http://cls-og.com/bundles/css/Default/sprite.png 404(未找到)

deployment rendering http-status-code-404 asp.net-mvc-4 kendo-ui

8
推荐指数
1
解决办法
5124
查看次数

找不到Django 404错误页面

我的项目名为homefood,当我运行server时,我得到了这个错误.任何人都有任何线索如何解决这个错误.

Page not found (404)

Request Method: GET

Request URL:    http://127.0.0.1:8000/

Using the URLconf defined in homefood.urls, Django tried these URL patterns, in this order:

^foodPosts/

^admin/

The current URL, , didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
Run Code Online (Sandbox Code Playgroud)

我的settings.py文件看起来像这样......

import dj_database_url
"""
Django settings for homefood project.

# Build paths inside the project like this: …
Run Code Online (Sandbox Code Playgroud)

python django django-urls http-status-code-404

8
推荐指数
1
解决办法
5万
查看次数

Heroku上的Symfony:403禁止您无权访问/在此服务器上

我已成功将我的Symfony 2应用程序部署到Heroku但现在,当我尝试访问它时,我收到以下403错误:

被禁止

您无权访问此服务器上的/.

这是Heroku的日志:

2015-07-29T14:31:41.827491+00:00 heroku[router]: at=info method=GET path="/" host=my-app.herokuapp.com request_id=557a70f4-ea11-4519-b8df-301b714f6ffa fwd="151.77.103.253" dyno=web.1 connect=0ms service=1ms status=403 bytes=387
2015-07-29T14:31:41.828428+00:00 app[web.1]: [Wed Jul 29 14:31:41.827438 2015] [autoindex:error] [pid 104:tid 140466989270784] [client 10.100.0.139:16096] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive
2015-07-29T14:31:41.829009+00:00 app[web.1]: 10.100.0.139 - - [29/Jul/2015:14:31:41 +0000] "GET / HTTP/1.1" 403 209 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36
Run Code Online (Sandbox Code Playgroud)

似乎Symfony(或Heroku?)正在尝试提供目录,/app/但我认为这是不正确的,如日志:

2015-07-29T14:31:41.828428 + …

php heroku http-status-code-403 http-status-code-404 symfony

8
推荐指数
2
解决办法
1万
查看次数

VueJS和Firebase,刷新时的历史模式404错误

我在路由器文件中删除了历史模式链接中的hashbang.现在,当我刷新页面时,我收到了404错误.

我试着按照这个链接

然后,我在firebase.json中添加了部分:

{
  "hosting": {
    "public": "dist",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

然而一切都没有改变.

我不明白为什么我还有这个错误.我尝试了很多东西,但我找不到解决它的东西.

这是我的路由器文件:

const router = new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/',
      redirect: '/catalog'
    },
    {
      path: '/catalog',
      name: 'Catalog',
      component: Catalog
    },
    {
      path: '/catalog/category/:category',
      name: 'ProductsList',
      component: ProductsList
    },
    {
      path: '/catalog/category/:category/product/:id',
      name: 'ProductDetail',
      component: ProductDetail,
    },
    {
      path: '/catalog/category/:category/product/create',
      name: 'CreateProduct',
      component: CreateProduct
    }
  ]
});
Run Code Online (Sandbox Code Playgroud)

http-status-code-404 firebase vue.js vuejs2 vuefire

8
推荐指数
1
解决办法
1312
查看次数

颤抖如何处理Image.network错误(例如404或错误的URL)

Image.network网址错误或目的地指向404时如何处理。

例如尝试

Image.network('https://image.tmdb.org/t/p/w92')
Run Code Online (Sandbox Code Playgroud)

http-status-code-404 flutter

8
推荐指数
6
解决办法
4750
查看次数

邮递员测试 - 使用 http 状态进行调节

我想检查答案是否正确。响应码为 200 或 500 时正确。后者需要区分响应正文中的字符串是正确的还是不正确的。它应该在单个测试中。

我已经尝试过简单的 if 子句,但它们不起作用。

pm.test("response is ok", function(){
    if(pm.response.to.have.status(200)){
        //do things
    }     
});
Run Code Online (Sandbox Code Playgroud)

编辑:

我使用的解决方案是

pm.test("response is valid", function(){
if(pm.response.code === 200){
    //is ok
} else if (pm.response.code === 500){
    if(pm.expect(pm.response.json().message).to.include("xyz")){
        //is ok
    } else {
       pm.expect.fail("Error 500"); 
    }
} else {
    pm.expect.fail("statuscode not 200 or 500");
}
Run Code Online (Sandbox Code Playgroud)

});

javascript testing http http-status-code-404 postman

8
推荐指数
1
解决办法
5613
查看次数