简体   繁体   English

Razor 页面中的 Wexbim 文件

[英]Wexbim Files in Razor Pages

I am working on a razor pages project that needs to view IFC files, so I converted the IFC file into Wexbim files to use the XbimWebUi library.我正在处理需要查看 IFC 文件的 razor 页面项目,因此我将 IFC 文件转换为 Wexbim 文件以使用 XbimWebUi 库。

My problem is when I use the Wexbim file from wwwroot I get this error "Uncaught Failed to fetch binary data from the server. Server code: 404. This might be due to the CORS policy of your browser if you run this as a local file.", so I uploaded my file to Cloudinary website and got a link for it and it works well.我的问题是当我使用来自 wwwroot 的 Wexbim 文件时,我收到此错误“未捕获无法从服务器获取二进制数据。服务器代码:404。如果您将其作为本地文件运行,这可能是由于浏览器的 CORS 策略造成的.”,所以我将我的文件上传到Cloudinary网站并获得了链接,它运行良好。

My question is how to do this throughout wwwroot folder without using an external link.我的问题是如何在不使用外部链接的情况下在整个 wwwroot 文件夹中执行此操作。

Thanks in advance.提前致谢。

My Code我的代码

<html>

<head>
    <title>xViewer</title>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

    <script src="~/Viewer/gl-matrix.js"></script>
    <script src="~/Viewer/jquery.js"></script>
    <script src="~/Viewer/webgl-utils.js"></script>

    <script type="text/javascript" src="~/Viewer/xbim-product-type.debug.js"></script>
    <script type="text/javascript" src="~/Viewer/xbim-state.debug.js"></script>
    <script type="text/javascript" src="~/Viewer/xbim-shaders.debug.js"></script>
    <script type="text/javascript" src="~/Viewer/xbim-model-geometry.debug.js"></script>
    <script type="text/javascript" src="~/Viewer/xbim-model-handle.debug.js"></script>
    <script type="text/javascript" src="~/Viewer/xbim-binary-reader.debug.js"></script>
    <script type="text/javascript" src="~/Viewer/xbim-triangulated-shape.debug.js"></script>
    <script type="text/javascript" src="~/Viewer/xbim-viewer.debug.js"></script>

    <style>

        html, body {
            height: 100%;
            padding: 0;
            margin: 0;
        }

        canvas {
            display: block;
            border: none;
            margin-left: auto;
            margin-right: auto;
            width: 100%;
            height: 100%;
        }
    </style>
    </head>
    <body>

        <div id="content">
            <canvas id="viewer"></canvas>

            <script type="text/javascript">
                var viewer = new xViewer('viewer');
                /*viewer.load("~/Uploads/SampleHouse.wexBIM");*/
                viewer.load("https://res.cloudinary.com/amostafah/raw/upload/v1623564775/SampleHouse_uacu4j.wexbim");
                viewer.start();
            </script>

        </div>
    </body>

</html>

The problem is actually related to Mime Mappings.这个问题实际上与 Mime 映射有关。 All you need is:所有你需要的是:

       app.UseStaticFiles(new StaticFileOptions
        {                
            ServeUnknownFileTypes = true
        });

You can check by accessing the path where you hold the wexbimfiles directly and serving a.png file from that folder.您可以通过访问直接保存 wexbimfiles 的路径并从该文件夹提供 .png 文件来进行检查。 If you get it then the path is fine.如果你得到它,那么路径很好。

If you get 404 when accessing http://localhost:58802/data/SampleHouse.wexbim, then this is mime type related.如果在访问 http://localhost:58802/data/SampleHouse.wexbim 时得到 404,那么这是与 mime 类型相关的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM