ASP.Net without codebehind
I would like to create an ASP.Net page without all the codebehind and designer stuff. Basically I want to go back to ASP classic, but keep the CLR and Base Class Library that makes .Net oh-so-wonderful. I'd like just a page something like this:
<html> <body> <div> <% int customerID = Request.QueryString["CustomerID"]; //Customer and DataAccess classes come from an extenal assembly Customer customer = DataAccess.GetCustomer(customerID); %> You asked for Customer with ID: <%=customerID;%><br /> Name: <%=customer.Name;%><br /> Phone: <%=customer.Phone;%><br /> </div> </body> </html>
However there seem to be some pro开发者_运维问答blems with that.
- The Request object is only available from within a Page object. I wish to completely delete the codebehind and designer pages.
- No intellisense
- Anything else I should be aware of before I get too deep into this?
- No idea how to start pulling in extenal libraries
You don't need to do anything in code-behind if you don't want to.
To import namespaces, use an import directive:
<%@ Import namespace="System.Web" %>
To import external libraries, use an Assembly directive:
<%@ Assembly Name="YourAssemblyName" %>
Importing System.Web will allow you intellisense access to the HttpContext.Current.Request
object. It will also give you intellisense for any other objects in that namespace, just like a code file.
I think your best bet is to look at ASP.NET MVC, specifically with the Razor View Engine.
You will still have some tooling around this though.
HttpContext.Current.Request
will give you the request.
精彩评论