如何在 Asp.net MVC 中使用 C# 访问 HTML 元素?

Mad*_*dhu 1 .net html c# asp.net-mvc asp.net-mvc-4

我正在使用 Asp.net MVC 做一个应用程序,在模型中,我需要检查我要显示的视图页面是否具有特定的元素。我id尝试使用WebBrowser类来遍历我的视图页面,但它显示错误消息如下。

`ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because   the current thread is not in a single-threaded apartment.` 
Run Code Online (Sandbox Code Playgroud)

在课堂上WebBrowser

所以有什么想法可以解决这个问题。

And*_*rei 5

使用 ASP.NET MVC 开发应用程序时,您可以完全控制输出 HTML。定义视图来声明 HTML 的外观。

您无法使用 C# 和 ASP.NET MVC 以编程方式访问 HTML 元素(DOM 树)