[英]ASP.Net without codebehind
我想创建一个没有所有代码隐藏和设计器东西的ASP.Net页面。 基本上我想回到ASP经典,但保留CLR和基类库使.Net非常好。 我想要一个像这样的页面:
<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>
然而,似乎有一些问题。
如果你不想,你不需要在代码隐藏中做任何事情。
要导入名称空间,请使用import指令:
<%@ Import namespace="System.Web" %>
要导入外部库,请使用Assembly指令:
<%@ Assembly Name="YourAssemblyName" %>
导入System.Web将允许您对HttpContext.Current.Request
对象进行智能感知访问。 它还将为您提供该命名空间中任何其他对象的智能感知,就像代码文件一样。
我认为你最好的办法是看看ASP.NET MVC,特别是使用Razor View Engine。
尽管如此,你仍然会有一些工具。
HttpContext.Current.Request
将为您提供请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.