Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between .aspx and .aspx.cs?

I'm not new to programming but am new to Visual Studio, MVC, C#, ASP.NET, and EXT.NET, i.e. all of the tools I am trying to use.

I am trying to create an Ext.Net 2.0 MVC4 project and was given a similar (in functionality) non-MVC project for reference.

I see that this non-MVC project has .aspx and .aspx.cs files. It seems like the .aspx file basically maps to the "View" in MVC that I want to make... And the .aspx.cs file has the functions that relate to the .aspx file - so is that like the "Controller"? Though the .aspx file also has some functions that seem to not be entirely view-related...

Could someone give me a quick overview or a place to start with this?

like image 664
Kalina Avatar asked Nov 01 '12 17:11

Kalina


People also ask

What is the difference between ASP and ASPX?

ASPX runs on . Net framework. ASP uses VBScript for its code. ASP.NET allows the use of C#, VB.NET and other languages.

What is .aspx mean?

Active Server Pages (ASPX) is a file format used by web servers and generated using the Microsoft ASP.NET framework - an open-source development framework used by web developers to create dynamic web pages, often with the . NET and C# programming languages.

What is the difference between .aspx and .ascx file?

aspx: The file extension of Web page. . ascx: The file name extension for the user control.

What is ASPX designer cs file?

aspx. designer. cs file contains all the definition of the controls that are being used by the page. It's just segregation of the code using partial class feature.


1 Answers

ASPX files usually will have the UI and will which is usually HTML tags, some ASP.NET server control embed code (which ultimately produce some HTML markups). ASPX.CS file (usually called the codebehind) will have server-side coding in C#.

If needed, I would relate ASPX page to View and ASPX.CS to Controller action methods.

You have to remember that in webforms, there are ASP.NET controls we will be using in the ASPX file to render some HTML. Examples are TextBox, DataGrid, etc. In MVC, there is nothing called Server control. The View will be pure, handwritten HTML.

If needed, you can create a Hybrid project which is a combination of MVC and webforms. Scott has a post explaining about it here.

No ViewState in MVC :)

When switching from ASP.NET Webforms to MVC, One important thing you have to understand is that MVC architecture tries to stick with the truth that HTTP is stateless. There is no viewstate available in MVC. So you need to make sure that you are repopulating the data in every HTTP Request, as needed. Folks usually run into problems in loading DropDownlist in MVC. There are a lot of answers here in SO about how to handle dropdown lists on postback (when form is posted).

I suggest that you look into some beginner-level tutorials on ASP.NET MVC and start building your app step-by-step, and if you run into any issues, post a (new) question with relevant details.

Good luck, and welcome to the wonderful world of MVC. :)

like image 87
Shyju Avatar answered Sep 17 '22 01:09

Shyju