Can't get Syncfusion working.

Hello,

I am trying to set up SyncFusion Blazor on my application but I am having an implementation problem. 
I followed the tutorial "Getting-started / Server side" (https://blazor.syncfusion.com/documentation/getting-started/server-side-blazor/) :
  • I have a server side project in .Net 3.1
  • I downloaded the SyncFusion.Blazor v18.1.0.53 nugget
  • I added in the _Imports.razor :

@using Syncfusion.Blazor
@using Syncfusion.Blazor.Calendars
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.Popups
@using Syncfusion.Blazor.Inputs

  • I added in the Startup.cs :
public void ConfigureServices (IServiceCollection services)
{
     services.AddSyncfusionBlazor ();
     ....
}
then
public void Configure (IApplicationBuilder app, IWebHostEnvironment env)
{
     // Register Syncfusion license
     Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense ("*** MyKey ***");
     ....
}
  • I added in the _Host:
    < link rel='nofollow' href="_content/Syncfusion.Blazor/styles/bootstrap4.css" rel="stylesheet" />


But I have thoses errors messages : 
  1. bootstrap4.css:1 Failed to load resource: the server responded with a status of 404 ()
  2. blazor.server.js:8 GET https://localhost:44346/_content/Syncfusion.Blazor/scripts/syncfusion-blazor.min.js net::ERR_ABORTED 404
However the files are present:

C:\Users\***\.nuget\packages\syncfusion.blazor\18.1.0.53\staticwebassets\styles\bootstrap4.css
C:\Users\***\.nuget\packages\syncfusion.blazor\18.1.0.53\staticwebassets\scripts\syncfusion-blazor.min.js

What have I missed?

Thank you for you help

Rémy


8 Replies

SU Sridurgha Uthayakumaran Syncfusion Team May 22, 2020 11:40 AM UTC

Hi Avanti, 

Greetings from Syncfusion.  

We have validated the reported issue and we are not able to reproduce the issue from our end and we suggest you to refer the style file in _Host.cshtml as in below format. 

<link rel='nofollow' href="_content/Syncfusion.Blazor/styles/bootstrap4.css" rel="stylesheet" /> 

For your convenience, we have created a sample rendering Calendar component and the same can be downloaded from the below link. 


Please get back to us if you need further assistance on this with the details like code example of your application, replication procedure and any illustrative details such as image or screen capture so that it will be helpful for us to validate from our end and provide the solution at the earliest. 

Please let us know if you have any concerns. 

Regards, 
Sridurgha U  




AV Avanti May 25, 2020 01:30 PM UTC

Hello Sridurgha,

Thanks for your help.

I finally found the problem, in Properties/launchSettings.json, I filled in the profile:

   "profiles": {
     "IIS Express": {
       "commandName": "IISExpress",
       "launchBrowser": true,
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Staging"
       }
     }

When I set back to "ASPNETCORE_ENVIRONMENT" in "Development" mode, it works.

The staging environment being necessary for us, how can we solve it?


JA Jesus Arockia Sankaran S Syncfusion Team May 28, 2020 03:57 AM UTC

Hi Avanti, 

Thank you for waiting for our response.  

We have checked the reported problem and we are able to reproduce it in our end. We suspect that static web assets are not loading properly for environment other than “Development” so we must load it in startup.cs file as in below code snippet.  

Code Snippet
startup.cs 

public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 
        { 
            if (env.IsEnvironment("Local") || env.IsEnvironment("Production") || env.IsEnvironment("Staging")) 
            { 
                app.UseStaticFiles(new StaticFileOptions 
                { 
                    FileProvider = new PhysicalFileProvider( 
                    @"C:\Users\${user-name}\.nuget\packages\syncfusion.blazor\18.1.0.54\staticwebassets"), 
                    RequestPath = "/_content/Syncfusion.Blazor" 
                }); 
            } 
. . . .  
(more code follow) 
} 


launchsetting.json 

{ 
  "iisSettings": { 
    "windowsAuthentication": false, 
    "anonymousAuthentication": true, 
    "iisExpress": { 
      "applicationUrl": "http://localhost:61979", 
      "sslPort": 44313 
    } 
  }, 
  "profiles": { 
    "IIS Express": { 
      "commandName": "IISExpress", 
      "launchBrowser": true, 
      "environmentVariables": { 
        "ASPNETCORE_ENVIRONMENT": "Local" 
      } 
    }, 
    "Development": { 
      "commandName": "IISExpress", 
      "launchBrowser": true, 
      "environmentVariables": { 
        "ASPNETCORE_ENVIRONMENT": "Development" 
      } 
    }, 
    "Azure Dev Spaces": { 
      "commandName": "AzureDevSpaces", 
      "launchBrowser": true 
    }, 
    "Production": { 
      "commandName": "IISExpress", 
      "launchBrowser": true, 
      "environmentVariables": { 
        "ASPNETCORE_ENVIRONMENT": "Production" 
      } 
    }, 
    "Staging": { 
      "commandName": "IISExpress", 
      "launchBrowser": true, 
      "environmentVariables": { 
        "ASPNETCORE_ENVIRONMENT": "Staging" 
      } 
    }, 
    "BlazorSyncEnv": { 
      "commandName": "Project", 
      "launchBrowser": true, 
      "environmentVariables": { 
        "ASPNETCORE_ENVIRONMENT": "Development" 
      }, 
      "applicationUrl": "https://localhost:5001;http://localhost:5000" 
    } 
  } 
} 



We have also created a sample for your reference that you can find from the below link.  


We request you to share more details such as image, video (screen capture), code snippet, sample application etc.. for cleat understanding if we misunderstood your point. 

Please get back to us if you need any further assistance on this. 

Regards, 
Jesus Arockia Sankaran S 



AF Andy Foong November 11, 2020 07:12 AM UTC

Hi,

I got the same problem and shock to see that the issue existed since May 2020. 

The solution above seems to be just workaround and will not work if we deploy to server. Do you have any permanent fix please?


FA Fabio Angela November 12, 2020 01:43 AM UTC

same for me
I've deployed on my PC as a Virtual Application and I guess that's the problem because instead looking into the right path ( e.g. http://localhost/MyWebApp/_content etc... ) it looks into http://localhost/_content ....

It's a mapping problem that has to be fixed


JA Jesus Arockia Sankaran S Syncfusion Team November 13, 2020 06:43 AM UTC

Hi Fabio, 
 
Thank you for prompting this query.  
 
We want to inform you that the reported issue is not with Syncfusion library and it is behavior of ASP.NET Core Blazor platform itself. We can refer the below GitHub issue for more details.  
 
 
Please let us know if you have any concerns.  
 
Regards, 
Jesus Arockia Sankaran S 





QU quang December 6, 2020 11:31 AM UTC

Hello,
I agree that this error come from ASP.NET Core Blazor platform itself.
But could we have a work-around for server deployment?
It's meaningless to use Syncfusion if what written can be never deployed to the clients. Thank you.

Sincerely,
Q.V


MK Muthukumar Kannan Syncfusion Team December 10, 2020 12:52 PM UTC

Hi Andy / Fabio / Quang ,

Thanks for your patience.

We have validated the reported issue related to deploying the application on the server with environment variables changes. As stated earlier, it is an issue from the ASP.NET Core Blazor platform itself. However, we can use below configuration to deploy the application in the server.

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsEnvironment("Local") || env.IsEnvironment("Production") || env.IsEnvironment("Staging"))
            {

#if (RELEASE)
                app.UseStaticFiles(new StaticFileOptions
                {
                    FileProvider = new PhysicalFileProvider(
                      Path.Combine(env.ContentRootPath, "wwwroot/_content/Syncfusion.Blazor/scripts")),
                    RequestPath = "/_content/Syncfusion.Blazor"
                });

#else
                app.UseStaticFiles(new StaticFileOptions
                {
                    FileProvider = new PhysicalFileProvider(
                    @"C:\Users\${user-name}\.nuget\packages\syncfusion.blazor\18.3.0.53\staticwebassets"),
                    RequestPath = "/_content/Syncfusion.Blazor"
                });
#endif
            }
          //...other snippets...
          }

Could you please check the deployment with the above workaround?

Please let us know if you have any concerns about that.

Regards,
Muthukumar K


Loader.
Up arrow icon