I’m trying to implement Google Analytics in my MVC website. First, I tried creating a GA account. Unfortunately, I’m developing locally on localhost which isn't a valid site URL, but I found a fix that will hopefully work here http://www.objectpartners.com/2011/05/26/setting-up-google-analytics-on-localhost/#comment-5960.
Then, I copied the generated JS tracking code and pasted it to a view. However, I found this article (http://analyticsimpact.com/2011/01/20/google-analytics-on-intranets-and-development-servers-fqdn/) about using NuGet package "GoogleAnalyticsTracker" which is supposed to let you track your site by using .NET framework. I followed these steps by adding the code to a controller, but the nothing is shown in the view.
I guess one solution would be creating a new GA account, copy the JS tracking code and paste it into /Views/Shared/_Layout.cshtml.
Anyone has experience implementing Google Analytics in a MVC4 application?
Thank you!
It's really as simple as:
Create a partial view named GoogleAnalytics
Copy & Paste the Analytics tracking JavaScript code from Google
Use #{ Html.RenderPartial("GoogleAnalytics"); } in a template which is used by all pages
Publish the site
Wait 24 hours for statistics to appear
This is my organised approach however you can put it in any location as long as the code is visible on every page you want to track.
Related
I have created a project with asp.net core web app with individual authentication now I want to edit the registeration page but I cant find it. In the documentation page say go to /Areas/Identity/Pages/Account/RegisterConfirmation.cshtml.cs.
However, I cant find the account folder inside my Pages folder
so what do you think I have done wrong with project?
Thanks
I believe you are looking to add Identity into your code. You would need to scaffold identity before you could see those codes. In summary, you would need to:
Create the project
Scaffold identity
Configure email sender (if any)
The official documentation is actually pretty straightforward and easy to follow.
"I cant find the account folder inside my Pages folder":
I think you are searching this URL
https://localhost:44374/Identity/Account/Register into your project
folder and finally you got to see below page: and there is no Register page
"So what do you think I have done wrong with project?":
No you haven't done anything worng with the project at all. While we
create the proejct with enabling the individual authentication it
doesn't create any Register page within the project as its build in
with the SDK which is not visiable in the project directory
Areas\Identity\Pages\ You can see the DLL files as below location.
Note: If you want to get that source code files then you can get from our official repository here. If you want to customize your identity then you can follow the guideline here
Hope above steps guided you accordingly.
So I have here a .NET C# web app that needs one page able to be viewed offline as a user could be off in the middle of 'whoop whoop' with no internet.
The order of events are:
User visits a form online
Store the webpage using HTML5 so they can visit it later offline
When online - the user then can submit the form to the database
I've been looking over HTML5 appcache however it seems to only reference physical .html or .php pages rather than storing pages which have been generated by 'Razor' .cshtml Views.
e.g. domain.com/path/view.
I haven't been able to find any relevant documentation for my problem either.
So is it possible to cache a .NET webapp ofline?
Although I have not tried it, and assuming your app uses ASP.NET MVC, this might help you:
Build an HTML5 Offline Application with Application Cache, Web Storage and ASP.NET MVC
It uses HTML5 Offline Web Application API (or HTML Application Cache). Note the comment on browser support.
The linked article shows a sample application, but I could not see a link to a downloadable source code. But one commenter appears to have recreated the project.
The appcache is what you need. Note that you specify the pages to be cached, but the browser never sees if the page is a static .html or generated via Razor. As long as the path you specify opens the right page, it will be cached.
I am developing an MVC5/EF6 web application hosted on Azure using Visual Studio 2013. I have just got to the portion of development whereby I need to create the reports. I was trying to use Microsoft.ReportViewer to achieve this and although it works perfectly locally it would appear that the WOW (WAWS) on a standard Azure website does not have/allow enough privileges to generate/return a PDF via a stream reader (http://social.msdn.microsoft.com/Forums/windowsazure/en-US/b4a6eb43-0013-435f-9d11-00ee26a8d017/report-viewer-error-on-export-pdf-or-excel-from-azure-web-sites?forum=windowsazurewebsitespreview). The suggestion from Microsoft was to convert the web site to a web role - I am prepared to do this however it seemed like a "no go" for most contributors - also I cant find any tutorials on the matter (I have posted a new question on this).
My question is, what are my options? SSRS is being deprecated so a server call is out, hand cranking a HTML page does not appeal. The closest I have found to a solution breaks the MVC pattern, but should work see here:
Rendering an RDLC report in HTML in ASP.NET MVC
Any help would be greatly appreciated!
Cheers
David
I ended up creating a web role to gain access to GDI+ and elevated WOWs rights, from there I was able to export directly to PDF which is just what I wanted. Not sure why so many other articles condemned this it seems to work perfectly and the cost differentiator does not seem too bad... yes it is more - however, experiments with the extra small VM has proved quite successful.
Im writing a web app using C# with ASP.NET 4.5/Entity as a backend. With Angular.js handling
most of the front-end/database query stuff. ASP.NET 4.5 makes it really easy to connect to
our active directory using windows authentication.
However will I run into problems when I scrap all the razor templates, and replace it with regular HTML/CSS and angular scripts. All I really need the active directory stuff for is to create permission for who can pull what file from our database.
Im pretty new to web apps, so far ive like the entity framework alot, but if you guys know a more efficient way (better back end) to do this feel free to tell me.
My app basically needs to allow users to upload spreadsheets and videos, search for them, and only allow access to users that are in certain AD groups.
We solved this problem by using MVC to render the HTML templates. In your controller or directive set the templateUrl to an action which does whatever logic is necessary to render the template for that user. Also, be sure to check user permissions in your AJAX calls.
Figured it out. Made a new web api controller
then added this function
public string getUser()
{
return User.Identity.Name;
}
haha that was easy.
However if anyone sees any errors i may run into doing it this way. Please point em out
I am trying to implement DotNetOpenid in my asp.net website. However, the more I try to read up on DotNetOpenid, the more confused I get. My initial goal is to allow user login process (similar to StackOverflow).
I attempted to get some help via this question dotnetopenid tutorial
but was unsuccessful (since I am not using MVC)
How can I get a tutorial that would help me accomplish that?
I would first start at the developers site
Coding Guidelines
Quick Start
Code Snippets
I have been posting my questions here Support Forum. Pretty helpful.
The ASP.NET OpenID web site (C#) project template isn't a tuturial, but it does create a functioning OpenID ASP.NET web site.
I just installed it and was able to get a site up and running. Here are a few gotchas that I ran into:
When you create a new project using the template, do not choose a deep path - this will create problems during database creation.
When you first run the application, you'll hit an exception - don't worry about it. When you get the YSOD, simply browse to the Setup.aspx page mentioned in the instructions.
If you don't have an OpenID, you'll need to get one. The initial page loaded after database creation has a 'Get OpenID' link if you need to get one. It's a simple process and only takes a few minutes.
Once you get through that, you'll have a working implementation of an OpenID web site.
You might also want to check out the DotNet OpenAuth ASP.NET Controls.
HTH
Edit
For anyone interested, there is also an ASP.NET MVC 2 OpenID web site (C#) template. I'm surprised #Andrew Arnott answered the other question and didn't mention these, since he is the author.