Frage

I created a generic controller class

namespace OxygenFramework.MvcController
{
  public class MvcController<TEntity> : Controller
    where TEntity : class
  {
    public void UpdateModelState(TEntity t)
    {
        ...
    }
  }
}

then I used it as below

namespace LeitnerMVC.Controllers
  {
    public class HomeController : MvcController<Account>
     {
    //
    // GET: /Home/
    public ActionResult Index()
    {
        UpdateModelState(t);
        return View();
    }
  }
}

BUT when run mvc application page shows this error

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.

after searched in web I found a way for solve it

  void Application_Start(object sender, EventArgs e)
    {                 
    ControllerBuilder.Current.DefaultNamespaces.Add("OxygenFramework.MvcController");
    }

But above solution does not work for me !!! and shows Http 404 error again

When use Controller instead of MvcController page shows without problem !!!

Can anyone help me ?

Update :

after many investigation I understand why this problem occurs but still I dont know how resolve that. WHEN I move source code of MvcController out of my framework assemby (OxygenFramework.MvcController) and move it into MVC project MvcController works but when I refrence MvcController from OxygenFramework assembly MVC shows 404 error !!! Now I know this problem occur because MvcController is into another assembly but I dont know how solve this problem

attention : only generic implimentation of MvcController is in OxygenFramework assembly and all of Controller is into the default Controllers folder

War es hilfreich?

Lösung

After many investigation I found problem I want to say @Agat thank you :)

But Solution : I used System.Web.Mvc.dll version 4.0 in my framework but used System.Web.Mvc.dll 5.0 in my MvcApplication ! This interference causes the 404 error from inheritance :D

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top