GetScriptHandler vs BundleConfig

Hi,


You made me register, and here we go.

I have a project which has recently started to include MVC and
Global.asax has these as it is:

void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
           Viewer.InitRoutes();
Viewer.SetLicensePath(Server.MapPath("~/External/GroupDocs/GroupDocs.Viewer.for.NET.lic"));
Viewer.SetRootStoragePath(Server.MapPath("~/testfiles/")); //Just for test!
GlobalConfiguration.Configure(WebApiConfig.Register);
       <span style="color:#2b91af;">AreaRegistration</span>.RegisterAllAreas();
       <span style="color:#2b91af;">RouteConfig</span>.RegisterRoutes(<span style="color:#2b91af;">RouteTable</span>.Routes);
       <span style="color:#2b91af;">FilterConfig</span>.RegisterGlobalFilters(<span style="color:#2b91af;">GlobalFilters</span>.Filters);
       <span style="color: rgb(43, 145, 175);">BundleConfig</span>.RegisterBundles(<span style="color: rgb(43, 145, 175);">BundleTable</span>.Bundles);                      </pre>        }</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">And when I run the Viewer from aspx files with the last three of the lines above commented, it works fine.</pre><pre style="font-family: Consolas; font-size: 13px; background: white;">But now I need to migrate to MVC, I need these bundleconfig, and it messes with the viewer.</pre><pre style="font-family: Consolas; font-size: 13px; background: white;"><br></pre><pre style="font-family: Consolas; font-size: 13px; background: white;">Just realized BunldeConfig might be necessary:</pre><pre style="font-family: Consolas; font-size: 13px; background: white;"><pre style="font-family: Consolas; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">BundleConfig</span>
{
    <span style="color:green;">// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862</span>
    <span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> RegisterBundles(<span style="color:#2b91af;">BundleCollection</span> bundles)
    {
        bundles.Add(<span style="color:blue;">new</span> <span style="color:#2b91af;">ScriptBundle</span>(<span style="color:#a31515;">"~/bundles/jquery"</span>).Include(
                    <span style="color:#a31515;">"~/Scripts/jquery-{version}.js"</span>));

        bundles.Add(<span style="color:blue;">new</span> <span style="color:#2b91af;">ScriptBundle</span>(<span style="color:#a31515;">"~/bundles/jqueryval"</span>).Include(
                    <span style="color:#a31515;">"~/Scripts/jquery.validate*"</span>));

        <span style="color:green;">// Use the development version of Modernizr to develop with and learn from. Then, when you're</span>
        <span style="color:green;">// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.</span>
        bundles.Add(<span style="color:blue;">new</span> <span style="color:#2b91af;">ScriptBundle</span>(<span style="color:#a31515;">"~/bundles/modernizr"</span>).Include(
                    <span style="color:#a31515;">"~/Scripts/modernizr-*"</span>));

        bundles.Add(<span style="color:blue;">new</span> <span style="color:#2b91af;">ScriptBundle</span>(<span style="color:#a31515;">"~/bundles/bootstrap"</span>).Include(
                  <span style="color:#a31515;">"~/Scripts/bootstrap.js"</span>));

        bundles.Add(<span style="color:blue;">new</span> <span style="color:#2b91af;">StyleBundle</span>(<span style="color:#a31515;">"~/Content/css"</span>).Include(
                  <span style="color:#a31515;">"~/Content/bootstrap.css"</span>,
                  <span style="color:#a31515;">"~/Content/site.css"</span>,
                  <span style="color:#a31515;">"~/Content/bootstrap-responsive.css"</span>));
    }
}</pre></pre></div>

Hello,


Thank you for your request. You have incorrect code.
1. You have set root storage twice - it should be set only once
2. You have missed this code line - Viewer.InitRoutes(); it should be the first code line of the Application_Start method.

Here is and example of the correct settings:
protected void Application_Start()
{
Viewer.InitRoutes();
Viewer.SetRootStoragePath(Server.MapPath("~/testfiles/"));
Viewer.EnableFileListRequestHandling(true);

AreaRegistration.RegisterAllAreas();

RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}

Also make sure that in the web.config you have set :

Best regards.