Blazor-Analytics Nuget not working when Deployed - google-analytics

I have a blazor WASM hosted project that I installed the Blazor-Analytics nuget package. I installed it on both the Server and the Client projects. There are 2 issues I am having with it.
When I put the on the App.razor it freezes the loading of the application. It just sits at the loading screen
<CascadingAuthenticationState>
<Router AppAssembly="#typeof(Program).Assembly" AdditionalAssemblies="new[] { typeof(BBQFriend.Components.PageComponents.Index).Assembly }">
<Found Context="routeData">
<AuthorizeRouteView RouteData="#routeData" DefaultLayout="#typeof(MainLayout)">
<NotAuthorized>
#if (!context.User.Identity.IsAuthenticated)
{
<RedirectToLogin />
}
else
{
<p>You are not authorized to access this resource.</p>
}
</NotAuthorized>
<Authorizing>
<Loading />
</Authorizing>
</AuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="#typeof(MainLayout)">
<div class="content">
<div class="section-title">
<h1>I think you're lost...</h1>
<div class="section-title-stripe"></div>
</div>
</div>
</LayoutView>
</NotFound>
</Router>
#*<NavigationTracker />*#
</CascadingAuthenticationState>
If i comment it out like above I can run the application. However, When i run the application locally in debug mode I can go on Google Analytics and see in RealTime the pages I am navigating to etc. It works.
I then deploy this to Azure and when i navigate on the live website hosted in Azure, nothing happens. I do not see any analytics being reported and do not see the pages i am navigating to realtime.
Why is this working Locally but not working when deployed?

Related

Drupal 9 - 403 error when viewing User Profile anonymously

I'm building out a new Drupal 9 site and have ran into a weird issue where I can not view any user profile page anonymously. I get a 403 error on the page and the only thing it spits out is "You are not authorized to access this page."
All of this people are active and not blocked. I thought it could be an issue with layout builder but it doesn't make a difference. I haven't had this issue with any content types, just user profiles.
The site is running on a bootstrap theme and is hosted via Pantheon. Here's what spits out the message when viewing a profile page anonymously:
<div class="region region-content">
<div data-drupal-messages-fallback="" class="hidden"></div>
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'block' -->
<!-- FILE NAME SUGGESTIONS:
* block--mainpagecontent.html.twig
* block--system-main-block.html.twig
x block--system.html.twig
* block.html.twig
-->
<!-- BEGIN OUTPUT from 'themes/composer/bootstrap/templates/block/block--system.html.twig' -->
You are not authorized to access this page.
<!-- END OUTPUT from 'themes/composer/bootstrap/templates/block/block--system.html.twig' -->
</div>
</div>
Any ideas as to what would be causing this issue?
For a anonymous user to be able to see user profile pages you need to grant that permission.
Go to
/admin/people/permissions
Under “User -> View user information” grant the necessary permission.
Now, think twice.
It might be a very bad idea to grant this kind of permission.
Consider all the impacts on security and privacy among others.

URL's Path are not working when deployed to IIS Server System

I have problem that when i deployed my ASP.NET MVC project to IIS Server System, the images url's add from CSS they are not taking exact path and in Angularjs unable send post or get request.
CSS sample code
<div class="container" style="background-image:url('../../Images/img/product-1.jpg')">
<div class="text-left">Welcome</div>
</div>
AngularJS sample code
var app=angular.module('myApp', ['ngRoute']);
app.controller('myCtrl', ['$scope', '$http', function($scope, $http){
$http({
method:"POST",
url:"/controller/action",
data:{id:1}
}.then(function(response){
console.log(response)
}, function(error){
console.log(error)
});
]});
so these are sample code what i have written in my project.
i have search internet i have found some solutions like
Installing StaticContent from add or remove features for IIS
changing application pool for authentication.
remove staticContent tags in web.config.
i have tried these thing evening i am unable solve my issue.
my error are:
GET http://18.xxx.xxx.xxx/controller/action 404 (Not Found)
GET http://18.xxx.xxx.xxx/Images/img/bg-img/top.jpg 404 (Not Found)
actual url should load like this
GET http://18.xxx.xxx.xxx/myApplication/controller/action 404 (Not Found)
GET http://18.xxx.xxx.xxx/myApplication/Images/img/bg-img/top.jpg 404 (Not Found)
Change the style mentioned in below style.
Notes: change the directly level.
<div class="container" style="background-image:url('~/Images/img/product-1.jpg')">
<div class="text-left">Welcome</div>
<div class="container" style="background-image:url('#Url.Content("~/Images/img/product-1.jpg")')">
<div class="text-left">Welcome</div>
Explanation of ~ vs /:
/ - Site root
~/ - Root directory of the application

Preact and Parcel - Routing issue after bundling

I've been seeking for a solution to this for over a month now.
I've built a personal landing page using parcel-bundler and preact. I am also using preact-router to handle my routing.
Here's some code.
Main App Component
class App extends Component {
render(props) {
return (
<div id='main'>
{/* Components outside of router persist
throughout all pages */}
<Header />
<Nav tabs={tabs} />
<Router>
<About default path='/about' />
<Skills path='/skills' />
<Books path='/books' />
</Router>
</div>
)
}
}
Nav Component
const Nav = ({ tabs }) =>
<nav>
{tabs.map(t => (
<p>
<Link activeClassName='active' href={ t.path }>{ t.title.toUpperCase() }</Link>
</p>
))}
</nav>
tabs.json
[
{
"title": "About",
"path": "/about"
},
{
"title": "Skills",
"path": "/skills"
},
{
"title": "Books",
"path": "/books"
}
]
So, whenever I run the page live using parcel's server, everything works as expected: I click on a tab, and the respective page/component gets rendered.
However, whenever I run parcel build blah blah, open my index.html and click on any tab, I get the following https://i.imgur.com/71ogrFA.png (screenshot of browser window when I click on a tab), and the URL bar of the browser changes to file:///C:/{route_name}.
I'm trying to understand why it is that my page works when I run it on parcel's live server, and why it doesn't work after build? It seem like, after build, clicking any tabs causes the browser to search for the page in the file system? Is that case? Ultimately, how can I fix this?
A leading slash in URLs makes them absolute to the root.
If the site is transported via HTTP, the root is the domain: <a href="/bar"> placed on a site with the URL http://example.com/foo/bar would point to http://example.com/bar.
However, in case of the file protocol that is used when you open a file from your PC in the browser, the root is the root folder of the current drive, usually C:. So if you opened the same file locally on file:///C:/some/path/foo/bar, the link would point to file:///C:/bar.
Most importantly, this means that this error is only present during local development. It won't occur once your site is hosted on an actual server.
You can run a local HTTP server with tools like XAMPP or MAMP to make sure the links work before deployment.
The parcel development server is also running a local HTTP server, that's why the links work fine there.

IIS Express doesn't serves images on ASP.NET Web Forms app, image location serves 404

I am creating an ASP.NET web form application from Visual Studio 2017.
I have created :
<div class="row">
<div class="col-md-4">
<img src="~\\image\\ap.jpeg" />
</div>
<div class="col-md-4">
<img src="~\image\ap.jpeg" />
</div>
<div class="col-md-4">
<img src="image/ap.jpeg" />
</div>
</div>
I ran the webapp from Visual Studio, but it only serves broken image links. While I copied the image location and pasted it to my browser : http://localhost:1905/~//image//ap.jpeg or http://localhost:1905/~/image/ap.jpeg or http://localhost:1905/image/ap.jpeg, it all complained
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
The image should be there, I have created the image folder just on the root of the webapp.
Why is this and how to remedy this ?
Links with ~ are for server controls and the single-slash should be forward
<img src="~/image/ap.jpeg" />
but they'll only work with runat server
// html tag with runat server.
<img runat="server" src="~/image/ap.jpeg" />
// server control.
<asp:Image runat="server"></asp:Image>
To make sure the html tag works (should work), add a slash to the beginning to signify the root
<img src="/image/ap.jpeg" />
The problem was simply caused by the wrong extension. It should be .jpg not .jpeg, which was totally my stupid fault here.
<img src="image/ap.jpg" /> works.
Thanks for the other responses.

Can I use an HTML base tag to resolve a virtual directory?

I have an ASP.NET MVC web application running in IIS as a subweb; let's say its path is something like http://mysite.com/subweb.
I have a view which serves content obtained from a CMS. The CMS editor has entered some content containing a relative image path <img src="/images/imga.png" />.
This works fine on the production server where the site is the root website, but not on the staging server where the site is a virtual directory under the root website
The path should be <img src="/images/imga.png" /> on the production server
and <img src="/subweb/images/imga.png" /> on the staging server.
Is it possible to use the <base> tag to resolve this image path?
<head>
<base href="http://mysite.com/subweb/" />
</head>
<html>
<body>
<img src="/images/imga.png" />
</body>
</html>
It doesn't seem to work. Can anyone explain why or if this is a workable approach? I don't want to require the content editor to have knowledge of the website deployment option (which changes between UAT and production).
Try
<img src="images/imga.png" />
to make it a relative URL. Of course it's not that easy, the content editor must be changed. But I do believed that is the problem. URLs starting with a / are resolved from... (wonders) the domain's top-level directory?
The base tag only affects relative URLs. Try changing your image tag to this:
<img runat="server" src="~/images/imga.png" />
This will work even in sub directories of your app. .Net will resolve the "~/" to your application root.

Resources