我在我的 asp.net 项目中使用 MySql。但我不想输入每一个“使用 MySql.Data.MySqlClient;” 每个 aspx.cs/aspx.vb 文件中的语句。如何在 web.config 文件中定义这些行?
我已经定义了一些命名空间,如下所示,但这仅适用于 aspx 页面:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.0"/>
<pages>
<namespaces>
<add namespace="System.Web.Configuration"/>
<add namespace="MySql.Data"/>
<add namespace="MySql.Data.MySqlClient"/>
</namespaces>
</pages>
</system.web>
</configuration>