2013-02-28 56 views
0

我是新来的,我得到一个错误,不知道如何解决。在2012年视觉工作室快递错误

我创建了一个新的mvc4项目(c#),为空模板。

然后我添加了一个控制器(MVC空模板),我把他的代码:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Mvc; 

namespace Testing.Controllers 
{ 
public class Testing2Controller : Controller 
    { 
    // 
    //GET: /Testing2/ 

    public string Index() 
    { 
     return "01111000100011"; 
    } 

    } 
} 

和我得到这样的:在 '/' 应用

服务器错误。

无法找到该资源。

说明:HTTP 404.您正在查找的资源(或其某个依赖项)可能已被删除,名称已更改或暂时不可用。请检查以下网址并确保它拼写正确。

请求的URL:/

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.17929

我的web.config文件是这样的:

<?xml version="1.0" encoding="utf-8"?> 

<configuration> 
    <appSettings> 
    <add key="webpages:Version" value="2.0.0.0" /> 
    <add key="webpages:Enabled" value="false" /> 
    <add key="PreserveLoginUrl" value="true" /> 
    <add key="ClientValidationEnabled" value="true" /> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
    </appSettings> 
    <system.web> 
    <httpRuntime targetFramework="4.5" /> 
    <compilation debug="true" targetFramework="4.5" /> 
    <pages> 
     <namespaces> 
     <add namespace="System.Web.Helpers" /> 
     <add namespace="System.Web.Mvc" /> 
     <add namespace="System.Web.Mvc.Ajax" /> 
     <add namespace="System.Web.Mvc.Html" /> 
     <add namespace="System.Web.Routing" /> 
     <add namespace="System.Web.WebPages" /> 
     </namespaces> 
    </pages> 
    </system.web> 
    <system.webServer> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <handlers> 
     <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /> 
     <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /> 
     <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> 
     <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*."  verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /> 
     <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /> 
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> 
    </handlers> 
    </system.webServer> 

</configuration> 

非常感谢你,我没有做什么

回答

0

你的控制器想法方法需要返回ActionResult。你需要做的是这样的:

public ActionResult Index() 
{ 
    return Content("01111000100011"); 
} 

更新

我只是注意到错误中提到的URL /。要在你的问题中找到控制器操作,你必须去/Testing2

+0

谢谢,但没有帮助 – 2013-03-01 00:02:01

+0

你有没有配置任何路由? – 2013-03-01 00:12:37

+0

我有这样的: 命名空间测试 { 公共类RouteConfig { 公共静态无效的RegisterRoutes(RouteCollection路线) { routes.IgnoreRoute( “{}资源个.axd/{*} PATHINFO”); routes.MapRoute( 名称: “默认”, 网址: “{控制器}/{行动}/{ID}”, 默认:新{控制器= “家”,行动= “指数”,ID = UrlParameter .Optional} ); } } } – 2013-03-01 01:01:13