Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 748205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:17:38+00:00 2026-05-14T14:17:38+00:00

i’m new in asp.net mvc 2. I’m trying to list all data from one

  • 0

i’m new in asp.net mvc 2.
I’m trying to list all data from one table(ms sql server table). as ORM I use Entity Framework. now, I’m tried to write something to do this:

Model:

    private uqsEntities _uqsEntity;
    public permissionRepository(uqsEntities uqsEntity)
    {
        _uqsEntity = uqsEntity;
    }

    public string getUserID()
    {
        return _uqsEntity.userPermissions.FirstOrDefault().ID.ToString();
    }

controller:

    private DataManager _dataManager;
    public HomeController(DataManager datamanager)
    {
        _dataManager = datamanager;

    }
    public ActionResult Index()
    {
        ViewData["Message"] = _dataManager.Permission.getUserID();

        return View();
    }

View

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2><%= Html.Encode(ViewData["Message"]) %></h2>
<p>
    To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
</p>

when I run app. , my app. fails.

No parameterless constructor defined
for this object. Description: An
unhandled exception occurred during
the execution of the current web
request. Please review the stack trace
for more information about the error
and where it originated in the code.

Exception Details:
System.MissingMethodException: No
parameterless constructor defined for
this object.

Source Error:

An unhandled exception was generated
during the execution of the current
web request. Information regarding the
origin and location of the exception
can be identified using the exception
stack trace below.

Stack Trace:

[MissingMethodException: No
parameterless constructor defined for
this object.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType
type, Boolean publicOnly, Boolean
noCheck, Boolean& canBeCached,
RuntimeMethodHandle& ctor, Boolean&
bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean
publicOnly, Boolean fillCache) +86
System.RuntimeType.CreateInstanceImpl(Boolean
publicOnly, Boolean
skipVisibilityChecks, Boolean
fillCache) +230
System.Activator.CreateInstance(Type
type, Boolean nonPublic) +67
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext
requestContext, Type controllerType)
+80

[InvalidOperationException: An error
occurred when trying to create a
controller of type
‘uqs.Controllers.HomeController’. Make
sure that the controller has a
parameterless public constructor.]
System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext
requestContext, Type controllerType)
+190 System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext
requestContext, String controllerName)
+68 System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase
httpContext, IController& controller,
IControllerFactory& factory) +118
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase
httpContext, AsyncCallback callback,
Object state) +46
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext
httpContext, AsyncCallback callback,
Object state) +63
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext
context, AsyncCallback cb, Object
extraData) +13
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+8679186 System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously)
+155

Version Information: Microsoft .NET
Framework Version:2.0.50727.4200;
ASP.NET Version:2.0.50727.4016

please, somebody, help me to catch problem.

Other classes:
DataManager.cs

public class DataManager
 {
    private uqsEntities _entity;

    public DataManager(string connectionString)
    {
        this._entity = new uqsEntities(connectionString);
    }

    private permissionRepository _permissionsRepository;
    public permissionRepository Permission
    {
        get
        {
            if (_permissionsRepository == null)
                _permissionsRepository = new permissionRepository(_entity);
            return _permissionsRepository;
        }
    }
}

ControllerFactory.cs

public class ControllerFactory : DefaultControllerFactory
    {
        public Type controllerType { get; set; }
        public ControllerFactory()
        {

        }
        protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
        {
            if (controllerType == null)
                base.GetControllerInstance(requestContext, controllerType);
            string connectionString = ConfigurationManager.ConnectionStrings["uqsEntities"].ConnectionString;
            return Activator.CreateInstance(controllerType, new DataManager(connectionString)) as IController;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:17:38+00:00Added an answer on May 14, 2026 at 2:17 pm

    I fix it, like this:

    protected void Application_Start()
    {
                AreaRegistration.RegisterAllAreas();
    
                RegisterRoutes(RouteTable.Routes);
                //by this code:
                ControllerBuilder.Current.SetControllerFactory(new ControllerFactory());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.