简体   繁体   中英

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.

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.

My question is how to do this throughout wwwroot folder without using an external link.

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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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