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 6118185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:24:26+00:00 2026-05-23T15:24:26+00:00

My web application is an Asp.Net MVC pattern. None of the .aspx pages have

  • 0

My web application is an Asp.Net MVC pattern. None of the .aspx pages have code behind files. I was told that since the application follows MVC pattern, the .aspx pages don’t have a codebehind file. All the C# coding is done inline.

My question is that, is it that we shouldn’t have code behind files for .aspx pages if we follow MVC pattern. I don’t see any difference between these .aspx pages and traditional ASP pages where we do inline coding. In order to take advantage of Asp.Net and maitaining the code / html shouldn’t we have a code behind file for every .aspx page?

It would be great if someone could clearly explain this.

Thanks in advance.

  • 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-23T15:24:27+00:00Added an answer on May 23, 2026 at 3:24 pm

    Asp.net MVC doesn’t use codebehinds that’s true. But. You shouldn’t think of your pages as traditional ASP pages, because they’re not. Majority of processing (as in codebehind) is done inside controller actions. ASPX pages barely display results of that processing (when action result is ViewResult or PartialViewResult).

    So we could say that controller actions "are" codebehinds for many ASPX files.

    That’s of course a very broad simplification of this, but you could understand it this way.

    Additional explanation

    You may argue that writing C# code in an ASPX file is very similar to writing ASP code, but let me make you think of it for a moment. In Asp.net WebForms whenever you added

    <asp:Repeater ... />
    

    what you basically did, was a foreach statement in a different form with some additional capabilities. In Asp.net MVC what you write is an actual foreach statement instead with any additional functionality that you want. Majority of time you’ll just render items without additional functionality so foreach will be:

    1. faster than rich server-side control
    2. simpler, because HTML rendered for each item will be approx. the same as repeater item’s template
    3. less resource hungry, because it’s just a simple language construct and not some server-side control that has to be instantiated, executed and saved (as in state)

    Why can a controller action be a codebehind for many ASPXs?

    Because we can have this kind of code

    public ActionResult Index()
    {
        var data = /* get some data */
        if (data.Count > 0)
        {
            /* first ASPX */
            return View("DisplayItems", data);
        }
        else
        {
            /* second ASPX */
            result View("DisplayEmpty");
        }
    }
    

    Not to even mention that what this code does is so much simpler than some complex page lifecycle processing that would need to handle both states which would lead to much more complex ASPX file having all the HTML.

    In Asp.net MVC code is very simple/basic because it only does what it needs to do and views are much simpler just as well, because each may only serve one single state/situation/purpose. No multifaceting as in Asp.net WebForms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a web application on Asp.Net MVC 3. Assume that we have
I have implemented a repository pattern in my asp.net mvc web application... But i
I have a web application built in the asp.net 2.0 MVC pattern. Now the
I have developed a MVC web application with ASP.NET MVC and im just wondering
I am building a web application using ASP.NET MVC that has two very distinct
I'm trying to write a web application in ASP.NET MVC that allows each user
I have a Asp.net MVC web application, containing mostly text. I want to put
Currently I'm trying to port a web application(ASP.NET MVC) to windows azure and have
For the web application (ASP.NET MVC) I'm currently developing, we have the following architecture
Other than the fact that ASP.NET MVC Web Application has more clarity in its

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.