[英]ASP.Net without codebehind
I would like to create an ASP.Net page without all the codebehind and designer stuff. 我想创建一个没有所有代码隐藏和设计器东西的ASP.Net页面。 Basically I want to go back to ASP classic, but keep the CLR and Base Class Library that makes .Net oh-so-wonderful.
基本上我想回到ASP经典,但保留CLR和基类库使.Net非常好。 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 problems with that. 然而,似乎有一些问题。
You don't need to do anything in code-behind if you don't want to. 如果你不想,你不需要在代码隐藏中做任何事情。
To import namespaces, use an import directive: 要导入名称空间,请使用import指令:
<%@ Import namespace="System.Web" %>
To import external libraries, use an Assembly directive: 要导入外部库,请使用Assembly指令:
<%@ Assembly Name="YourAssemblyName" %>
Importing System.Web will allow you intellisense access to the HttpContext.Current.Request
object. 导入System.Web将允许您对
HttpContext.Current.Request
对象进行智能感知访问。 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. 我认为你最好的办法是看看ASP.NET MVC,特别是使用Razor View Engine。
You will still have some tooling around this though. 尽管如此,你仍然会有一些工具。
HttpContext.Current.Request
将为您提供请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.