2

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

18
  • 1. what page (url) shows you 404? 2. What web engine do you use? 3. Is HomeController located in Controllers folder? Commented Nov 9, 2013 at 17:38
  • 1. localhost/Home/Index 2. MVC (Razor) 3. Yes Commented Nov 9, 2013 at 17:40
  • Add "LeitnerMVC.Controllers" to the default namespaces. Commented Nov 9, 2013 at 17:56
  • I added it but did not work !!! :( Commented Nov 9, 2013 at 18:02
  • 1
    "When use Controller instead of MvcController page shows without problem", just to clarify... That means if you inherit HomeController from Controller -- that's ok, but when from MvcController -- not ok? (As generally, everything works for me in any way). Commented Nov 9, 2013 at 18:39

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.