zoukankan      html  css  js  c++  java
  • 把源码放到服务器部署webservice调用出错 MVC C#

    C# WebService在本地调用正常,同样的代码布睹到服务器上总是调用报如下错误

    Server Error in '/' Application.


    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

    Requested URL: /service/trackservice.asmx/Logon

    解决办法,在路由配置文件中添加配置

    routes.IgnoreRoute("{*x}", new { x = @".*.asmx(/.*)?" }); 

    public static void RegisterRoutes(RouteCollection routes)
            {
                /*本地用VS2010新建了一个MVC4工程,添加一个默认的webservice,包含helloworld方法,本地运行,或直接部署到本地的IIS,调用webservice没有任何问题,直接把源码考到服务器,部署,网站打开没有问题,显示webservice页面也没有问题,点击调用方法的时候出错,
    Server Error in '/' Application.
    
    The resource cannot be found.
    
    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 
               */
                routes.IgnoreRoute("{*x}", new { x = @".*.asmx(/.*)?" }); 
                //routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.MapRoute(
                    "Default", // Route name
                    "{controller}/{action}/{id}", // URL with parameters
                    new { controller = "Account", action = "LogOn", id = UrlParameter.Optional } // Parameter defaults
                );
               
            }

    困惑多天的问题,一句代码解决。

  • 相关阅读:
    使用NPOI导入导出标准Excel
    winform ListView应用之分组、重绘图标、网格线
    在网页中显示CHM
    动态表单(javascript实现)
    批量上传文件时,js验证文件名不能相同
    IE开发人员工具无法使用
    卸载方法 gnu grub version 0.97
    VS.Net 2003/VC6.0常用快捷键集合
    SQL SERVER 与ACCESS、EXCEL的数据转换
    通用获取父节点/子节点/子节点下所有节点ID的存储过程
  • 原文地址:https://www.cnblogs.com/huangzhen22/p/5287197.html
Copyright © 2011-2022 走看看