CSS and images of a Razor Class Library not loaded if adding reference directly from DLL - razor

I have a RCL with razor components that have their own scoped CSS and some resources (like png background, etc.) in the wwwroot folder.
If I consume this library from a Blazor server app doing the add reference to the project in the same solutions, it works perfectly like described here
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/class-libraries?view=aspnetcore-6.0&tabs=visual-studio
But If I compile the RCL and add the reference pointing directly to the DLL nor CSS neither images are loaded
<Project Sdk="Microsoft.NET.Sdk.Web">
<!-- it works-->
<ItemGroup>
<ProjectReference Include="..\BlazorRCL.Library\BlazorRCL.Library.csproj" />
</ItemGroup>
<!-- doesn't work
<ItemGroup>
<Reference Include="BlazorRCL.Library">
<HintPath>..\BlazorRCL.Library\bin\Release\net6.0\BlazorRCL.Library.dll</HintPath>
</Reference>
</ItemGroup>
-->
</Project>

Related

Working with dotnet and angular2

I have recently integrated a boostrap admin template (based on Angular2) in an asp project (here is the repo)
The thing is: when I am running tsc, all files compile well, but if I change html files, if the web browser (let say firefox) opened the project previously, the page never change, but if I open a new web browser (let say chrome) I can see the change. Now, if I change an html again, neither one can detect new changes in html files.
I think it is dotnet configuration, because I used the bootstrap angular template which is set up with npm lite server, and it has not any problems (I mean: change .ts files, .html files and it refresh always well)
To reproduce the problem, these are the steps:
npm install
dotnet restore
dotnet run
go to /pages/login <- It displays everything ok
edit login.component.ts: template: <h1> Hello!</h1>
go to /pages/login <- It keeps showing the login form
go to /pages/login (google-chrome) <- It shows the change
edit login.component.ts: template: <h1> Hello World!</h1>
go to /pages/login (google-chrome) <- It only shows Hello!
The asp app were caching the pages, so I changed the web.config
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="no-cache, no-store" />
<add name="Pragma" value="no-cache" />
<add name="Expires" value="-1" />
</customHeaders>
</httpProtocol>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>

Azure custom 404 page

I have created a web application using Microsoft Azure and uploaded static html pages to the web application.
It works fine, however, I would like to set a custom 404 page. Where or how can I do this using the Azure portal ?
Just to be clear, this is not a visual studio project, it's just some static html files. I just want to tell azure to use my 404 page instead of the default text it displays when a page cannot be found.
EDIT
Please note, this has nothing to do with IIS. I dont even have a web.config file. I am simply hosting some static html files in Azure and want a custom 404 page. I have already made the 404.html page.
Seems like you have to add a web.config file in your root directory. This seems like a workaround, but doing that and adding the following code works:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/404.asp" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
Follow these steps to configure a custom 404 page for a Azure Static Web App:
Create a file named staticwebapp.config.json in root page (same folder as starting page i.e. index.html)
put these lines inside it:
{
"responseOverrides": {
"404": {
"rewrite": "/404.html"
}
}
}
Put your custom 404 page in root or subfolder (in this example 404.html is in root folder)
After a lot of testing and research, it was found that using responseMode="ExecuteURL" would result in a correct redirect, but the browser would report 200 Status rather than a 404. To fix this we removed the "/" and changed to responseMode="File" based on insight from this post: web.config errors fail with responseMode="File"
We are just hosting a simple static HTML site, not a web app, and this code worked:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<customErrors defaultRedirect="404.html" mode="RemoteOnly">
<error statusCode="404" redirect="404.html" />
<error statusCode="500" redirect="500.html" />
</customErrors>
</system.web>
<system.webServer>
<httpErrors existingResponse="Replace" defaultResponseMode="File" errorMode="Custom">
<remove statusCode="404" />
<error statusCode="404" path="404.html" responseMode="File" />
<remove statusCode="500" />
<error statusCode="500" path="500.html" responseMode="File" />
</httpErrors>
</system.webServer>
</configuration>

Windows Azure Website and static html in Blob storage

So I have a .NET MVC app published in an Azure Website which should serve static html pages stored in a blob container when clicking on a corresponding hyperlink.
My questions are:
The way to access a blob in Azure is
https://blobtest.blob.core.windows.net/container/htmlpage1.html,
however the peculiar part is when I login into my Azure Site and the url is
something like:
http://azuretestwebapp.azurewebsites.net/user123 and if I click
on a hyperlink to my html blob it can't help but normally take me to
blob azure site (well of course). Therefore I am wondering if there
is a way to have a url similar to this:
http://azuretestwebapp.azurewebsites.net/user123/container/htmlpage1.html
considering that the html pages are stored elsewhere in Azure.
If this is not feasible using an Azure Website or by storing
static html pages in Blob, what would be a better approach?
Thank you in advance for your time.
You can modify your web.config for your site to forward requests for static pages to blob storage using a redirect rule. Then the static content will be stored in and served from blob storage.
Place the following in a file named web.config (or modify your existing web.config) and put the web.config in the folder site/wwwroot on your website, next to the site content.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="static" stopProcessing="true">
<match url="static/(.*)" />
<action type="Rewrite" url="https://blobtest.blob.core.windows.net/static/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Better late than never. Azure Blob requires the host header to be set correctly also otherwise it'll 404.
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="static" stopProcessing="true">
<match url="static/(.*)" />
<action type="Rewrite" url="https://blobtest.blob.core.windows.net/static/{R:1}" />
<serverVariables>
<set name="HTTP_HOST" value="blobtest.blob.core.windows.net" />
</serverVariables>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Please remember to Allow Server Variable {HTTP_HOST} in URL rewrite.
https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/setting-http-request-headers-and-iis-server-variables
You could also set this in applicationhost.config section.
<location path="Default Web Site">
<system.webServer>
<rewrite>
<allowedServerVariables>
<add name="HTTP_HOST" />
</allowedServerVariables>
</rewrite>
</system.webServer>
</location>

Push Service plugin for BlackBerry WebWorks 2.0.0.54 error (Cordova 3.2) (newest versions of both SDKs)

I'm trying to use the Push Service plugin in my BlackBerry Webworks app (BB10 in HTML5).
I added the plugin through the command line like the documentation says, and checked that the com.blackberry.push folder was infact inside my plugins folder in my project. I ran the app in my device and the Web Inspector gave the next error:
TypeError: 'undefined' is not an object (evaluating 'window.webworks.defineReadOnlyField')
This error appears when the plugin tries to define the push constants like SUCCESS or INVALID_PPG_SUBSCRIBER_STATE, so obviously the plugin never starts to work and I can't use the push service.
I have my Push credentials fine (they work fine in my OS 7 app), and I was very carefull when I wrote the config.xml file. Here it is:
<widget id="Sample"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0" version="0.0.1">
<name>Sample</name>
<license href="http://www.apache.org/licenses/LICENSE-2.0"/>
<author email="something#somwhat.com" href="http://www.something.com">Something</author>
<content src="splash.html"/>
<access uri="http://www.mypushserver.com/Registro_Portalesv4/modules/Register" subdomains="true"></access>
<access origin="*"/>
<preference name="fullscreen" value="true"/>
<preference name="webviewbounce" value="true"/>
<description>Example</description>
<icon src="img/icono.png"/>
<feature id="blackberry.app"/>
<feature id="blackberry.push" />
<feature id="blackberry.system" />
<feature id="blackberry.invoked" />
<feature id="blackberry.ui.dialog" />
<feature id="org.apache.cordova" required="true" version="1.0.0" />
<rim:permissions>*
<rim:permit>access_shared</rim:permit>
<rim:permit>post_notification</rim:permit>
<rim:permit system="true">_sys_use_consumer_push</rim:permit>
<rim:permit>read_device_identifying_information</rim:permit>
<rim:permit>access_pimdomain_messages</rim:permit>
<rim:permit>bbm_connect</rim:permit>
<rim:permit>run_when_backgrounded</rim:permit>
</rim:permissions>
<rim:invoke-target id="example.sample.invoke.push">
<type>APPLICATION</type>
<filter>
<action>bb.action.PUSH</action>
<mime-type>application/vnd.push</mime-type>
</filter>
</rim:invoke-target>
<!-- Have an invoke entry here for when a notification is clicked on in the BlackBerry Hub -->
<!-- This will cause the application to be opened -->
<rim:invoke-target id="example.sample10.invoke.open">
<type>APPLICATION</type>
<filter>
<action>bb.action.OPEN</action>
<mime-type>text/plain</mime-type>
</filter>
</rim:invoke-target>
</widget>
What I did notice was that the function "window.webworks.defineReadOnlyField" is located in the webworks-1.0.4.11.js file wich I don't have included in my project because I'm using cordova.js as the BlackBerry WebWorks Documentation, Upgrading to WebWorks 2.0 suggested. So I think that maybe the push plugin is not updated for the new SDK or I'm missing something as well.
Any ideas? Thanks in advanced!
PS: I'm porting my app from Phonegap Android, and worked fine when I ported it to Blackberry, except for the plugins, wich I had to add and adapt so they could work (except for the push plugin).
The problem solves by downloading the newest version of the PushService Plugin (updated 10 hours after I posted the question), that has fixed all the problems I mentioned on my question.
Also, don't forget to add a tag with the ppg url to you config.xml file, otherwise the push service won't work.

adobe air native extension config files

I've been googling for something seemilgly simply, but I can't seem to find an answer: I am building some adobe native extension (ios/android). The native code is expecting to find a config.plist (ios) or .properties(android) file to work. The file is expected to be in the main res bundle (ios) or assets folder (android).
How should the adobe air app developer provide this file? Obviously I cannot package it inside the .ane file since it's app-specific...
Thanks!
I think you should be looking to the application descriptor for this sort of information. Eg info.plist additions can be added to the descriptor by adding the InfoAdditions node of the iphone section, for example:
<iPhone>
<InfoAdditions>
<![CDATA[
<key>UIRequiresPersistentWiFi</key>
<string>NO</string>
]]>
</InfoAdditions>
</iPhone>
http://help.adobe.com/en_US/as3/iphone/WS789ea67d3e73a8b2-48bca492124b39ac5e2-7ffb.html
And android has the manifest additions:
<android>
<manifestAdditions>
<![CDATA[
<manifest>
<uses-permission android:name="android.permission.INTERNET"/>
<application>
<receiver ... />
</application>
</manifest>
]]>
</manifestAdditions>
</android>