I asked this question in stackoverflow but no answers so I think it would fit here better.

I have a unity webgl project and an asp.net mvc project.

I need to show the webgl content in a view.

The first thing that came to my mind was to simply copy the content of the index.html that unity gave me and paste it in a .cshtml file and change the addresses. But when I do this the incorrect header error pops up.

Am I doing some thing wrong or everything wrong. should I change my method entirely?

I also added these file extensions to the web.config

  <!-- Unity 5.x -->
  <remove fileExtension=".mem" />
  <mimeMap fileExtension=".mem" mimeType="application/octet-stream" />
  <remove fileExtension=".data" />
  <mimeMap fileExtension=".data" mimeType="application/octet-stream" />
  <remove fileExtension=".memgz" />
  <mimeMap fileExtension=".memgz" mimeType="application/octet-stream" />
  <remove fileExtension=".datagz" />
  <mimeMap fileExtension=".datagz" mimeType="application/octet-stream" />
  <remove fileExtension=".unity3dgz" />
  <mimeMap fileExtension=".unity3dgz" mimeType="application/octet-stream" />
  <remove fileExtension=".jsgz" />
  <mimeMap fileExtension=".jsgz" mimeType="application/x-javascript; charset=UTF-8" />

2 Answers 2


This question has already an answer in StackOverflow given by the user kenoni. I'm quoting the answer:

Basically, you copy all the file references to your view and of course your canvas container with the code that initializes it.

Add everything that is a css style file with


And everything that is a js file with


So you`ll have something similar to this

    ViewBag.Title = "Stage";


    var gameInstance = UnityLoader.instantiate("gameContainer", "../webgl/Build/Builds.json", {onProgress: UnityProgress});

<div class="webgl-content">
    <div id="gameContainer" style="width: 960px; height: 600px"></div>
    <div class="footer">
        <div class="webgl-logo"></div>
        <div class="fullscreen" onclick="gameInstance.SetFullscreen(1)"></div>
        <div class="title">Figurines</div>

Don`t forget to add unityweb mime type to web.config

      <remove fileExtension=".unityweb" />
      <mimeMap fileExtension=".unityweb" mimeType="application/octet-stream" />

The generated index.html file from unity webgl build have a html5 canvas in it. You have to use that canvas to your intended platform or vice versa.

  • \$\begingroup\$ as I mentioned , I copied that canvas and some script that came with it in to my cshtml file but the incorrect header check error poped up. \$\endgroup\$
    – Henjin
    Commented Jun 19, 2016 at 4:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .