与 Webform 相比,ASP.NET MVC 是否提供了更适合与浏览器无关的解决方案?

发布于 2025-01-05 03:32:49 字数 758 浏览 4 评论 0原文

希望这个问题不会令人困惑,但我可以帮助澄清它,并且有一个明确的答案:是或否(当然还有为什么)。我使用针对 Windows 环境和 IE 的 ASP.NET Webforms 开发了许多内部 Intranet 应用程序。这使得 Windows 身份验证和拖放 ASP.NET 服务器控件等功能能够非常出色地工作,并且焦点通常集中在功能上,而不是网站的华丽或外观上;我不是在这里向大众销售产品。

然而,一些用户开始使用 Mac,并且我们知道默认浏览器是 Safari。遗憾的是 Safari 不支持 Windows 身份验证。另外,许多现成的 ASP.NET 服务器控件无法像在 IE 中那样正确呈现。另外,我还必须考虑 .js 中所需的所有差异。

现在从内部业务的角度来看,拥有单一企业平台并不罕见,因此假设用户使用 IE 也不是问题。然而,随着越来越多的 Mac 的推出,弥合差距以使这些 Intranet Web 应用程序与浏览器无关,这可能会在开发时间上产生很大的差异。

我想知道 ASP.NET MVC 在这个问题上是否有优势。我知道它不能解决 Windows Authentican 问题(也请提供解决方案),但我想知道,由于服务器控件没有像 Web 表单那样使用,在尝试制作 Web 应用程序时,使用 MVC 是否是有利的选择跨浏览器兼容?我不介意使用 MVC 而不是 Webform,如果有文档记录或获得了有关为什么 MVC 更适合跨浏览器使用的知识,请与它交谈。如果经验表明 MVC 呈现其控件的方式与 Web 表单中的服务器控件相比在不同浏览器中更好,那么这主要是我想要确定的。

有人知道这件事吗?谢谢!

Hopefully this question is not to confusing, but I can help clear it up and there is a definitive answer: Yes or No (and why of course). I develop a lot of internal intranet applications using ASP.NET Webforms targeted for the Windows Environment and IE. This allows things like Windows Authentication and the drag-and-drop ASP.NET server controls work extreamly well and the focus is typically on the function rather than the pazzaz or the look of the site; I'm not selling products here to the masses.

However some users are starting to use Macs, and as we know the default browser is Safari. Unfortunantly Safari does not support Windows Authentication. To add on, a lot of the out-of-the box ASP.NET server controls don't render properly as they do in IE. Plus I have to take into account all the differences I need in my .js as well.

Now looking at this from an internal busniess perspective, having a single enterprise platform is not uncommon, so assuming the users are on IE is not a problem. However as more Macs get introduced, bridging the gap to make these intranet web apps browser agnostic can be quite a difference in development time.

I was wondering if ASP.NET MVC has a leg up on this issue. I know it does not solve the Windows Authentican issue (chime in on this as well for solutions), but I was wondering since server controls were not being used like with web forms, if using MVC was the advantageous choice when trying to make web applications cross browser compatible? I don't mind doing MVC as opposed to webforms, and if there is documented or gained knowledge on why MVC works better for cross browser use, then speak to it. If experience shows the way that MVC renders its controls as opposed to server controls from webforms is better across different browsers, this is mainly what I am trying to detmine.

Does anyone know about this? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

彼岸花似海 2025-01-12 03:32:49

ASP.NET MVC 为您提供了关于如何呈现 HTML、CSS 和 JavaScript 的更多控制,因为您没有为您呈现这些内容的所有内置控件。由于您可以完全控制这些元素,因此您更能够以跨浏览器的方式进行开发。这给开发者带来了更多的负担。这是典型的权力与责任的权衡。

ASP.NET MVC gives you more control about how HTML, CSS, and JavaScript is rendered because you don't have all of the built-in controls that render this for you. Since you have full control over these elements, you are more enabled for developing in a cross-browser manner. This puts more burden on developers. It's a classic power vs. responsibility trade off.

挽清梦 2025-01-12 03:32:49

MVC 确实消除了服务器控件的损坏的 html、视图状态的巨大占用空间,并且通常使渲染的 html 更加干净和高效。所以回答你的问题,是的,MVC 将使你更容易获得干净的 html,保持你编写的方式,而不需要 ASP.NET 的渲染破坏一切。

MVC does do away with the mangled html of server controls, the huge footprint of viewstate, and generally makes the rendered html much cleaner and more efficient. So to answer your question, Yes, MVC will make it easier for you to have clean html that stays just the way you wrote it, without having asp.net's rendering mangle everything.

叹倦 2025-01-12 03:32:49

Safari 支持 Windows 身份验证。如果您遇到问题,您可以提供一些具体信息吗?

Web 表单控件(使用较新版本的 asp.net)通常可以很好地跨浏览器工作。问题是,如果不这样做,就很难找到他们。我也遇到过它们不能很好地与 IE6 配合使用的问题,在 Web 表单中跟踪它们并修复它们并不困难。但如果您想要拖放控件,那就需要权衡。

对于 MVC,不存在类似于 Web 表单的控件概念。您可以控制传送给客户端的所有内容,包括 HTML、CSS 和 Javascript 文件。您确实可以使用 HTML 帮助器将模型渲染到相应的 HTML 控件。您将编写的额外代码量取决于您要完成的任务。由于您可以控制交付给客户端的所有资产,因此可以更轻松地跟踪奇怪的一次性浏览器特定问题。

使用 MVC 并不意味着您不会遇到跨浏览器问题,但您一定会遇到。它可能更容易修复,但如果您在 Web 表单方面有经验,您应该能够实现相同的结果。

Windows authentication is supported in Safari. If you are facing issues can you give some specifics.

The web form controls (with newer version of asp.net) usually work across browsers fine. The problem is when it doesn't, it is hard to track them down. I have also had issues where they didn't work well with IE6, tracking them and fixing them is little hard in Web Forms. But that is trade off if you want drag and drop controls.

With MVC, there is no concept of controls similar to web forms. You control everything that is delivered to the client, the HTML, CSS and Javascript files. You do have HTML helpers to render your models to corresponding HTML controls. The amount of extra code you will be writing will depend on the task you are trying to accomplish. Since you control all the assets delivered to the client it makes it easier to track bizarre one off browser specific issues.

Using MVC doesn't mean you won't run into cross browser issues, you will. It may be easier to fix but then if you are experienced in web forms you should be able to achieve the same results.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文