Questions tagged [asp.net-webpages]

ASP.NET Web Pages is a page-centric lightweight development framework from Microsoft for building dynamic web sites.

ASP.NET Web Pages is the third web development model released by Microsoft after ASP.NET Web Forms and the ASP.NET MVC framework. Web Pages saw the introduction of Razor, a template syntax that enables the embedding of server-side code (C# or VB) within HTML markup. In this respect, the Web Pages framework offers a similar web development experience as that provided by PHP, classic ASP and other scripting technologies. This is deliberate, as the Web Pages framework is designed primarily to attract classic ASP and PHP developers to the ASP.NET stack - offering a "low concept count" introduction to ASP.NET.

Web Pages are developed using .cshtml (C#) or .vbhtml (VB) files. Typically, a file represents a page in a web site and will contain both the server-side code to manage the programming logic, and the HTML, CSS and JavaScript to be rendered to the browser.

Web Pages supports a template system based on layout files and the ability to dynamically include the contents of other files within a parent file at runtime. Web Pages also introduces a simple data access technology - the Database helper - based on the C# 4.0 dynamic type.

Despite the emphasis on simplicity, the Web Pages framework provides developers access to the entire .NET framework, enabling development of complex web sites.

More information at http://www.asp.net/web-pages

441 questions
4
votes
2 answers

Page.Culture vs Thread.CurrentThread.CurrentCulture

I have been using Thread.CurrentThread.CurrentUICulture with System.Threading and System.Globalization, for a while now to manually set the language used by my ASP.net pages, mainly WebForms and WebPages with Razor. See MSDN:…
AceShot
  • 350
  • 3
  • 10
4
votes
3 answers

Invoke OnClientClick of button in code behind

I have an button in my aspx web page, which should be 'clicked' in my code behind c# code. The OnClientClick method then call a JS confirm dialog box and so the btn_Click function only get executed when user click 'OK'... This is my code so…
ZerOne
  • 1,296
  • 6
  • 20
  • 40
4
votes
1 answer

Precompile ASP.NET Web Pages razor (*.cshtml) files

For an MVC project, there is the true property that can be set in the csproj file, see e.g. here. However, that has no effect in my Web Pages kind of project. Is there a similar switch that I could use? Note: Typical…
Borek Bernard
  • 50,745
  • 59
  • 165
  • 240
4
votes
3 answers

Could not load type ASP.ViewSwitcher

I added FriendlyUrls package via NuGet to my asp.net web pages project. When I debug the solution it returns error that ASP.ViewSwitcher in ViewSwitcher.ascx could not load. I did not find anything on the internet about this issue. Could anybody…
user2061217
4
votes
1 answer

Is _AppStart.cshtml an official part of ASP.Net MVC?

_AppStart.cshtml is not mentioned often, and when it is, it seems to be mentioned as part of WebMatrix / ASP.Net Web Pages as opposed to MVC proper. Furthermore, this high-scoring StackOverflow answer claims that _AppStart.cshtml "is not used in…
anon
  • 4,578
  • 3
  • 35
  • 54
4
votes
4 answers

Is using a Web API as dataprovider for a website efficient?

I was thinking about setting up a project with Web API. Basically build the API first and program the web site using this API. Although it's sound promising I was wondering: If I separate the logic in a nice way, I might end up retrieving data on a…
Stefan
  • 17,448
  • 11
  • 60
  • 79
4
votes
1 answer

When/Why Should I Use C#'s "WebPageExecutingBase.Href()" Method?

I tried searching Google and Stack Exchange for an answer to this question, and while it did yield some documentation on the Href() method (documentation I have seen before), It seems that questions on this method are either very obscure or…
VoidKing
  • 6,282
  • 9
  • 49
  • 81
4
votes
1 answer

Is using the Cache in WebMatrix user-specific or application-specific?

If I were to use AppState variables as opposed to Session variables, I would not be storing data user-specifically. That is, if one user changes an AppState variable, it remains changed for all users on a site (it is application specific). My…
VoidKing
  • 6,282
  • 9
  • 49
  • 81
4
votes
1 answer

How much can I trust ASP.NET Request Validation with Web Pages/WebMatrix vs. XSS?

I have read (and am coming to terms with) the fact that no solution can be 100% effective against XSS attacks. It seems that the best we can hope for is to stop "most" XSS attack avenues, and probably have good recovery and/or legal plans…
VoidKing
  • 6,282
  • 9
  • 49
  • 81
4
votes
1 answer

Razor code block usage

I'm just getting started with webpages and I can't quite figure out why a code block doesn't work. I need to conditionally display a WebGrid. Before I started I have this:
@grid.GetHtml()
Now I try to insert an if statement:
Neil Dobson
  • 1,239
  • 1
  • 12
  • 24
3
votes
6 answers

Different behaviours for two different submit buttons?

I am trying to have two submit buttons in my form - one accepts meetings; the other declines them. They will both have different behaviours. How can I do is in my C# code? The functionality I want is essentially if(isPost) { if(//accept button…
Eamonn O'Brien
  • 123
  • 1
  • 9
3
votes
2 answers

Disable Razors default .cshtml handler in a ASP.NET Web Application

Does anyone know how to disable the .cshtml extension completely from an ASP.NET Web Application? In essence I want to hijack the .cshtml extension and provide my own implementation based on a RazorEngine host, although when I try to access the…
mythz
  • 141,670
  • 29
  • 246
  • 390
3
votes
2 answers

Razor Pages On Server Validation returning for without some fields

I'm having an issue with a server side validation with Razor Pages (ASP.Net Core 2.0) I have a page that creates a record http://localhost:56876/Entries/Create?employeeID=112345 my code behind file for the OnGet looks like: [BindProperty] …
causita
  • 1,607
  • 1
  • 20
  • 32
3
votes
2 answers

Formatting string as email address

This SELECT returns the email address from the project owner: var selectEmailData = "SELECT User.Email FROM Projects INNER JOIN User ON Projects.ProjectOwner = User.UserId WHERE ProjectId=@0"; var dataEmail = db.Query(selectEmailData,…
Mendelsohn
  • 31
  • 1
3
votes
1 answer

Using ASP.NET 5 without MVC (simple Web Forms/Web Pages)

The company I work for is creating pixel perfect high performance oriented large scale systems. One of our system's stack is based on simple straightforward highly tuned ASP.NET without any web controls, just simple PHP/ASP style server pages. HTML…
NOP-MOV
  • 792
  • 2
  • 8
  • 28
1 2
3
29 30