asp.net - ASP.net 中的错误 : BC30037: Character is not valid

标签 asp.net vb.net

我已经开始学习asp.net了。我完成了基础知识,现在我开始构建小型应用程序。 我正在使用 VS 2012 并使用 VB 创建了空的 Web 应用程序项目。

我可以看到自动创建的 web.config,下面是其中写入的行:

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
    <system.web>
      <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5"  />
    </system.web>

</configuration>

我创建了 Default.aspx 文件并编写了以下代码行:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" %>

<%
    HelloWorldLabel.Text = "Hello, world!";
%>


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label runat="server" id="HelloWorldLabel"></asp:Label>
    </div>
    </form>
</body>
</html>

当我在浏览器上运行此应用程序时,我在该页面上收到以下错误:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: BC30037: Character is not valid.

Source Error:


Line 2:  
Line 3:  <%
Line 4:      HelloWorldLabel.Text = "Hello, world!";
Line 5:  %>
Line 6:  

Source File: c:\users\anjum.banaras\documents\visual studio 2012\Projects\Students\Students\Default.aspx    Line: 4 

有人可以帮我解决这个问题吗?我只是 ASP.NET 的初学者。您的帮助可以节省我很多时间。

提前感谢您!!

最佳答案

您已将页面的编程语言设置为 VB (Visual Basic),但它所提示的行是用 C# 语法编写的。要么将该行更改为有效的 VB 代码:

HelloWorldLabel.Text = "Hello, world!"

(我认为删除 ; 就足够了,但我从来没有编写过 VB 代码,所以我不确定)

或将页面语言更改为C#:

<%@ Page Language="c#" AutoEventWireup="false" CodeBehind="Default.aspx.vb" %>

关于asp.net - ASP.net 中的错误 : BC30037: Character is not valid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24115131/

相关文章:

c# - 我可以获得 HttpGet 设置的操作别名以包含同名的 css 文件吗?

c# - 如何检查数据网格单元格是否存在?

asp.net - 如何访问下拉列表中所选项目的值?

vb.net - 如何制作表单后面窗口的屏幕截图?

c# - ASP.NET MVC - 如何在登录页面上显示未经授权的错误?

asp.net - 有没有办法知道是否有人为您的网站添加了书签?

vb.net - 如何使用 Visual Studio 2010 创建的 Excel 加载项单击在 Excel 中创建的自定义上下文菜单时执行操作

c# - 有没有一种方法可以通过一个命令更改'n'标签的颜色?

vb.net - 是否可以绘制点线或虚线?

asp.net - 什么条件会导致 Web 应用程序及时编译?