Error trying to access ASP NET MVC page C#: "HTTP 404. The Resource you are Looking for (or one of its dependencies) could have been Removed"

Asked

Viewed 210 times

0

Hey, guys, a problem I can’t seem to solve.

My project is ASP NET MVC5 with C#.

I went to create another page in my project and simply when I run it is not recognized. I did the same way I always did and it’s not working.

The error " HTTP 404 appears. The Resource you are Looking for (or one of its dependencies) could have been Removed".

This is the Controller:

public class GruposDeUsuariosControllers : Controller
{
   
    public ActionResult RedirecionarPaginaDePesquisa()
    {
        GruposDeUsuariosViewModel modelo = new GruposDeUsuariosViewModel();
        try
        {
            return View("PaginaPesquisarGruposDeUsuarios", modelo);
        }
        catch (Exception e)
        {
            TempData["MENSAGEM_ERRO"] = e.Message;
            return View("PaginaPesquisarGruposDeUsuarios", modelo);
        }
    }

}

The page is named 'Paginapesquisargruposdeusuarios.cshtml', it is within the path "Views/Groupsthis" and has practically nothing in the content, only:

<h1>Página</h1>

I’m using Visual Studio 2012 (yes, very old, but the client only has this one) and I don’t know what else to do REAL.

Looks like something pretty silly or bug msm.

Anyone who can help me I’d be most grateful, because this is urgent :(

Thanks in advance!

  • what url you are using to access the page?

  • If you are not returning the same view as actionResult, it would be interesting to use Redirecttoaction ("Actionqueretornaview", "Nameoontroller")

  • So the problem is that it doesn’t even get into the method

2 answers

0

You can try using the Redirecttoaction, because from what I understand you are not returning the view to the current action but another view from another controller. (this is one of the alternatives, there are other).

public class GruposDeUsuariosControllers : Controller
{
   
    public ActionResult RedirecionarPaginaDePesquisa()
    {
        GruposDeUsuariosViewModel modelo = new GruposDeUsuariosViewModel();
        try
        {
            //Primeiro é a nome da Action e o segundo o nome controller
             RedirectToAction ("PaginaPesquisarGruposDeUsuarios", GruposDeUsuarios)
        }
        catch (Exception e)
        {
            TempData["MENSAGEM_ERRO"] = e.Message;
            //Primeiro é a nome da Action e o segundo o nome controller
              RedirectToAction ("PaginaPesquisarGruposDeUsuarios", GruposDeUsuarios)
        }
    }

}
  • I’ve changed, but he doesn’t even enter the method

  • paste the message of Exception that is generating here in the comments

  • it would be interesting to put the controller, model and view tbm so that we can understand the route

0

Starting from what you said you never get into this method Redirecionarpaginadepesquisa, check its default route and the call for this action is correct, normally the default action is set with index, in your case it should specify the full route.

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

Perhaps, this link can be of use to you.

Browser other questions tagged

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