css3pie在MVC,在哪里放置pie.htc文件? [英] css3pie in MVC, where to place the pie.htc file?

查看:317
本文介绍了css3pie在MVC,在哪里放置pie.htc文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用 Css3pie 在我的MVC项目渲染圆角面板,但有没有运气这么远。<​​/ p >

我按照正常的html页面样品和它的作品完美,但不是在我的MVC项目。
我认为这是事做与在MVC被混淆了pie.htc'文件的路径

我放在项目文件夹(根),并在我的CSS文件中的'pie.htc'文件,我使用:
行为:网址(/PIE.htc);

我觉得MVC路由器需要进行修改,以接受HTC文件扩展名?
对不起与MVC即时通讯新。有没有人尝试pie.htc,并在其MVC项目的工作,请大家帮帮忙?

谢谢!


解决方案

作为一个方面说明(也许它无论如何都会解决您的问题),如果你不希望有你的根宏达文件,你可以做下面来解决固有的行为相对路径的问题。这不是prettiest解决方案,但它工作得很好 -

在你的CSS,定义行为:行为:网址(CSS3PIE);

然后在你的Global.asax.cs具有下列code:

 保护无效的Application_BeginRequest(对象发件人,EventArgs的发送)
{
    CheckForCSSPIE();
}私人无效CheckForCSSPIE()
{
    如果(!Regex.IsMatch(Request.Url.ToString(),CSS3PIE))
    {
        返回;
    }    常量字符串AP prelativePath =〜/内容/ CSS / PIE.htc
    VAR路径= VirtualPathUtility.ToAbsolute(AP prelativePath);
    Response.Clear();
    Response.Status code =(INT)的HTTPStatus code.MovedPermanently;
    Response.RedirectLocation =路径;
    到Response.End();
}

它只是寻找任何请求匹配CSS3PIE,并从正确的位置返回宏达文件。

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!

解决方案

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.

这篇关于css3pie在MVC,在哪里放置pie.htc文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆