Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between ascx and .cshtml?

I have this in my index.cshtml:

@{
    ViewBag.Title = "Home Page";
}

@{
    Html.RenderPartial("~/Views/Home/Test.cshtml");
}

and this in my controller:

 [ChildActionOnly]
        public ActionResult Test()
        {
            return View();
        }

I am not able to understand what is the fundamental difference between using .ascx and .cshtml in RenderPartial method? Both works for me. What is the real difference? Can anybody explain?

like image 525
Jaggu Avatar asked Sep 08 '11 09:09

Jaggu


People also ask

What is the difference between ASPX and Cshtml?

One major advantage to aspx compared to cshtml is that you can view and edit the page itself (WUSIWYG kind of) using the design tab. With cshtml files you might as well use notepad to edit your html page. You are working "in the dark". @nivs1978: I actually find this to be a down-side of it.

What is Cshtml file used for?

What is a CSHTML file? A file with . cshtml extension is a C# HTML file that is used at server side by Razor Markup engine to render the webpage files to user's browser.

What is difference between HTML and Cshtml?

html is strictly processed by the client, typically a browser. cshtml is the file extension that refers to the razor view engine. In addition to straight html, these files also contain C# code that is compiled on the server prior to the pages being server up to the browser..

Is Cshtml the same as Razor?

razor helps you embed serverside code like C# code into web pages. cshtml is just a file extension. razor view engine is used to convert razor pages(. cshtml) to html.


1 Answers

There are two different view engines you can use for asp.net mvc3 web applications. Razor (.cshtml) and ASPX (*.aspx / *.ascx).

Take a look at this post about their differences:

What is the difference between Razor and ASPX?

like image 53
Tobias Avatar answered Oct 23 '22 03:10

Tobias