Doubt with Microsoft version . NET Framework Asp.net mvc

Asked

Viewed 325 times

0

Doubt, am I using the wrong version? The image shows Version Information: Microsoft . NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34274

On my hosting server says this:

ASP, Asp.NET 3.5, Asp.NET 4.0, Asp.NET 4.5 Ajax extensions for Asp.NET HTML, CSS, XML and Javascript MVC3, MVC4, MVC5 Plesk Control Panel in English Flash, WML and WAP support

After uploading a site made in Asp.net mvc, I have an error message: 403 - Forbidden: Access is denied.

So I made a site with only 1 controller and managed the view, added it on the web.config :

To show me the error and upload the files to the main httpdocs directory, now generates me an error message:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

On the route this so:

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

namespace WebSiteTeste
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}

in the Controller:

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

namespace WebSiteTeste.Controllers
{
    public class DefaultController : Controller
    {
        // GET: Default
        public ActionResult Index()
        {
            return View();
        }
    }
}

on the index:

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

On the web config:

  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <customErrors mode="Off"/>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  • Shows the codigo of cotroller, and the url, apparently the error is simply Not Found, ie did not find the path.

  • @Joelramosmichaliszen, ?

  • Cara shows the url of the controller/action and route config

  • @Joelramosmichaliszen, I updated the question with several details, see if it is in agreement. I thank you

  • The error of your picture is the 404 and in your question you say it is the 403 - Forbidden: Access is denied.. Could you specify your problem better?

  • @Randrade, I don’t think you read the question right, look at this: "After uploading a site made in Asp.net mvc, I have an error message: 403 - Forbidden: Access is denied. So I made a site with only 1 controller and generated the view, added on web.config : To show me the error and upload the files to the main directory httpdocs, now generates an error message:"

  • @itasouza Li yes. But the error you posted is not 403. The problem of the error now is in my answer below. As for 403, there’s no way I can help you without his information.

  • @itasouza which url gave the error?

  • I’ll explain you better, I did the full site on Asp.net mvc, I did the creation of a virtual directory is upload the files, ai I had the error 403, as I did not know why, so I made a common site with only 1 controller, generated the view and added some settings on web.config and then generated another error (404) that this in my question, I made the changes of your answer, it worked.

  • If you are still receiving error 403, open a specific question about it. Several times the problem is in the hosting

  • @Randrade, I think the problem is this : http://answall.com/questions/107413/como-configurar-rotas-quando-a-applies%C3%A7%C3%A3o-na-esta-na-raiz-do-servidor-Asp-net-mvc

Show 6 more comments

1 answer

1


Very simple. You are calling the Home controller in your RouteConfig, but your controller’s name is DefaultController.

Simply change the name of your controller or the name in your controller RouteConfig.

 public class HomeController : Controller

or

 routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Default", action = "Index", id = UrlParameter.Optional }
            );

The way your code is your application does not find the controller, so error 404 (not found).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.