MVC中的css3pie,pie.htc文件放在哪里?

发布于 2024-10-15 14:06:14 字数 355 浏览 1 评论 0原文

我一直在尝试在我的 MVC 项目中使用 Css3pie 来渲染圆角面板,但到目前为止还没有运气。

我按照正常 html 页面的示例进行操作,它运行得很好,但在我的 MVC 项目中却不起作用。 我认为这与 MVC 中混淆的“pie.htc”文件的路径有关,

我将“pie.htc”文件放在项目文件夹(根)和我的 css 文件中,我使用: 行为: url(/PIE.htc);

我认为 MVC 路由器需要修改以接受 htc 文件扩展名? 抱歉,我是 MVC 新手。有没有人尝试过pie.htc并让它在MVC项目中工作,请帮忙?

谢谢!

I've been trying to use the Css3pie in my MVC project to render rounded corner panel but have no luck so far.

I follow the sample with normal html page and it works perfectly but not in my MVC project.
I think it is something to do with the path of the 'pie.htc' file that is being confused in MVC

I place the 'pie.htc' file in project folder (root) and in my css file, i use:
behavior: url(/PIE.htc);

I think the MVC router needs to be modified to accept htc file extension?
Sorry im new with MVC. Has anyone tried pie.htc and have it working in MVC project, please help?

Thanks!

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

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

发布评论

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

评论(3

花辞树 2024-10-22 14:06:14

作为旁注(也许它无论如何都会解决您的问题),如果您不想在根目录中使用 .htc 文件,您可以执行以下操作来解决行为固有的相对路径问题。这不是最漂亮的解决方案,但效果很好 -

在您的 css 中,将行为定义为:behavior: url(CSS3PIE);

在您的 Global.asax.cs 中有以下代码:

protected void Application_BeginRequest(Object sender, EventArgs e)
{
    CheckForCSSPIE();
}

private void CheckForCSSPIE()
{
    if (!Regex.IsMatch(Request.Url.ToString(), "CSS3PIE"))
    {
        return;
    }

    const string appRelativePath = "~/Content/css/PIE.htc";
    var path = VirtualPathUtility.ToAbsolute(appRelativePath);
    Response.Clear();
    Response.StatusCode = (int)HttpStatusCode.MovedPermanently;
    Response.RedirectLocation = path;
    Response.End();
}

然后 查找与“CSS3PIE”匹配的任何请求并从正确的位置返回 .htc 文件。

As a side note (and maybe it will fix your issue anyway) if you don't want to have the .htc file at your root, you can do the following to get around the relative pathing issues inherent with behaviors. It's not the prettiest solution, but it works well -

In your css, define the behavior as:behavior: url(CSS3PIE);

Then in your Global.asax.cs have the following code:

protected void Application_BeginRequest(Object sender, EventArgs e)
{
    CheckForCSSPIE();
}

private void CheckForCSSPIE()
{
    if (!Regex.IsMatch(Request.Url.ToString(), "CSS3PIE"))
    {
        return;
    }

    const string appRelativePath = "~/Content/css/PIE.htc";
    var path = VirtualPathUtility.ToAbsolute(appRelativePath);
    Response.Clear();
    Response.StatusCode = (int)HttpStatusCode.MovedPermanently;
    Response.RedirectLocation = path;
    Response.End();
}

It will simply look for any request matching "CSS3PIE" and return the .htc file from the correct location.

关于从前 2024-10-22 14:06:14

将以下内容添加到 Global.asax 文件的 RegisterRoutes(RouteCollection paths) 方法中

routes.IgnoreRoute("pie.htc");

Add the following to the RegisterRoutes(RouteCollection routes) method of the Global.asax file

routes.IgnoreRoute("pie.htc");
撩心不撩汉 2024-10-22 14:06:14

在样式表中,添加以下行为

behavior: url("/Content/PIE/PIE.css")

In your stylesheet, add the following behavior:

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