|
16 | 16 | #end
|
17 | 17 |
|
18 | 18 | #add-js-interop-file-to-getting-started-server
|
19 |
| - Add the `telerik-blazor.js` file to your main index file - `~/Pages/_Host.cshtml`: |
| 19 | + Add the `telerik-blazor.js` file to your main index file: |
| 20 | + |
| 21 | + * `~/Pages/_Host.cshtml` for .NET 3.x - .NET 5 |
| 22 | + * `~/Pages/_Layout.cshtml` for .NET 6 |
20 | 23 |
|
21 | 24 | **HTML**
|
22 |
| - |
| 25 | + |
23 | 26 | @[template](/_contentTemplates/common/js-interop-file.md#js-interop-file-snippet)
|
24 | 27 |
|
25 | 28 | @[template](/_contentTemplates/common/js-interop-file.md#enable-static-assets)
|
26 | 29 | #end
|
27 | 30 |
|
28 | 31 | #js-interop-file-snippet
|
29 |
| - <head> |
30 |
| - . . . |
31 |
| - <script src="_content/Telerik.UI.for.Blazor/js/telerik-blazor.js" defer></script> |
32 |
| - |
33 |
| - <!-- For Trial licenses use |
34 |
| - <script src="_content/Telerik.UI.for.Blazor.Trial/js/telerik-blazor.js" defer></script> |
35 |
| - --> |
36 |
| - </head> |
| 32 | +```` |
| 33 | +<head> |
| 34 | + . . . |
| 35 | + <script src="_content/Telerik.UI.for.Blazor/js/telerik-blazor.js" defer></script> |
| 36 | +
|
| 37 | + <!-- For Trial licenses use |
| 38 | + <script src="_content/Telerik.UI.for.Blazor.Trial/js/telerik-blazor.js" defer></script> |
| 39 | + --> |
| 40 | +</head> |
| 41 | +```` |
37 | 42 | #end
|
38 | 43 |
|
39 |
| - |
40 | 44 | #theme-static-asset-snippet
|
41 |
| - <head> |
42 |
| - . . . |
43 |
| - <link rel="stylesheet" href="_content/Telerik.UI.for.Blazor/css/kendo-theme-default/all.css" /> |
44 |
| - |
45 |
| - <!-- For Trial licenses use |
46 |
| - <link rel="stylesheet" href="_content/Telerik.UI.for.Blazor.Trial/css/kendo-theme-default/all.css" /> |
47 |
| - --> |
48 |
| - </head> |
| 45 | +```` |
| 46 | +<head> |
| 47 | + . . . |
| 48 | + <link rel="stylesheet" href="_content/Telerik.UI.for.Blazor/css/kendo-theme-default/all.css" /> |
| 49 | +
|
| 50 | + <!-- For Trial licenses use |
| 51 | + <link rel="stylesheet" href="_content/Telerik.UI.for.Blazor.Trial/css/kendo-theme-default/all.css" /> |
| 52 | + --> |
| 53 | +</head> |
| 54 | +```` |
49 | 55 | #end
|
50 | 56 |
|
51 | 57 | #enable-static-assets
|
|
59 | 65 | #end
|
60 | 66 |
|
61 | 67 | #enable-static-assets-snippet
|
62 |
| - // Startup.cs |
63 |
| - namespace MyBlazorAppName |
| 68 | +<div class="skip-repl"></div> |
| 69 | +````Startup.cs |
| 70 | +namespace MyBlazorAppName |
64 | 71 | {
|
65 | 72 | public class Startup
|
66 | 73 | {
|
67 | 74 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
68 | 75 | {
|
69 | 76 | //more code may be present here
|
70 |
| - |
| 77 | +
|
71 | 78 | //make sure this is present to enable static files from a package
|
72 | 79 | app.UseStaticFiles();
|
73 |
| - |
| 80 | + |
74 | 81 | //more code may be present here
|
75 | 82 | }
|
76 | 83 | }
|
77 | 84 | }
|
| 85 | +```` |
| 86 | +````Program.cs |
| 87 | + |
| 88 | +//more code may be present here |
| 89 | +
|
| 90 | +//make sure this is present to enable static files from a package |
| 91 | +app.UseStaticFiles(); |
| 92 | + |
| 93 | +//more code may be present here |
| 94 | +```` |
78 | 95 | #end
|
79 | 96 |
|
80 | 97 |
|
81 | 98 |
|
82 | 99 | #app-paths
|
83 |
| - Add the following to your main index file (`~/Pages/_Host.cshtml` for a server-side Blazor app and `wwwroot/index.html` for a client-side Blazor app): |
| 100 | + Add the following to your main index file: |
| 101 | + |
| 102 | +* Client-Side Blazor app - `wwwroot/index.html` |
| 103 | +* Server-Side Blazor app |
| 104 | + * `~/Pages/_Host.cshtml` for .NET 3.x and .NET 5 |
| 105 | + * `~/Pages/_Layout.cshtml` for .NET 6 |
84 | 106 | #end
|
85 | 107 |
|
| 108 | +#register-telerik-service-server |
| 109 | +<div class="skip-repl"></div> |
| 110 | +````Startup.cs |
| 111 | +namespace MyBlazorAppName |
| 112 | +{ |
| 113 | + public class Startup |
| 114 | + { |
| 115 | + public void ConfigureServices(IServiceCollection services) |
| 116 | + { |
| 117 | + //more code may be present here |
| 118 | + services.AddTelerikBlazor(); |
| 119 | + } |
| 120 | + |
| 121 | + //more code may be present here |
| 122 | + } |
| 123 | +} |
| 124 | +```` |
| 125 | +````Program.cs |
| 126 | +//more code may be present here |
| 127 | +
|
| 128 | +builder.Services.AddTelerikBlazor(); |
| 129 | + |
| 130 | +//more code may be present here |
| 131 | +```` |
| 132 | +#end |
| 133 | + |
| 134 | +#register-telerik-service-client |
| 135 | +<div class="skip-repl"></div> |
| 136 | +````.NET_3.x_and_.NET_5 |
| 137 | +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; |
| 138 | +using Microsoft.Extensions.DependencyInjection; |
| 139 | +using System.Threading.Tasks; |
| 140 | +using System.Net.Http; |
| 141 | +using System; |
| 142 | + |
| 143 | +namespace ClientBlazorProject.Client // make sure this matches your actual WASM project namespace |
| 144 | +{ |
| 145 | + public class Program |
| 146 | + { |
| 147 | + public static async Task Main(string[] args) |
| 148 | + { |
| 149 | + // sample host builder for a WASM app, yours may differ |
| 150 | + var builder = WebAssemblyHostBuilder.CreateDefault(args); |
| 151 | + builder.RootComponents.Add<App>("app"); |
| 152 | + builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); |
| 153 | + // there may be more code here |
| 154 | +
|
| 155 | + // register the Telerik services |
| 156 | + builder.Services.AddTelerikBlazor(); |
| 157 | +
|
| 158 | + // there may be more code here |
| 159 | + // sample host builder for a WASM app, yours may differ |
| 160 | + await builder.Build().RunAsync(); |
| 161 | + } |
| 162 | + } |
| 163 | +} |
| 164 | +```` |
| 165 | +````.NET_6 |
| 166 | +using ClientBlazorProject; |
| 167 | +using Microsoft.AspNetCore.Components.Web; |
| 168 | +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; |
| 169 | +
|
| 170 | +// sample host builder for a WASM app, yours may differ |
| 171 | +var builder = WebAssemblyHostBuilder.CreateDefault(args); |
| 172 | +builder.RootComponents.Add<App>("#app"); |
| 173 | +builder.RootComponents.Add<HeadOutlet>("head::after"); |
| 174 | +
|
| 175 | +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); |
| 176 | +
|
| 177 | +// register the Telerik services |
| 178 | +builder.Services.AddTelerikBlazor(); |
| 179 | +
|
| 180 | +await builder.Build().RunAsync(); |
| 181 | +```` |
| 182 | +#end |
0 commit comments