Browser Links - Nonstop Signalr Calls in MVC 5 application - asp.net-mvc

I've created a new MVC 5 Project in VS2013 and when I create the project I gave the authentication mode to none because I planned to use signalr in my project later.
I didn't install any signalr related files instead of the two signalr js files (in my scripts folder). And there are no any startup class or OWIN.
But when I run my application there are signalr calls going and going using longpooling. These things can be viewed in the firebug console.
Previously I've used signalr with many projects using VS 2012 MVC4 this is the first time I'm using MVC5. And this slows down my application. How this could be happened.
Here is the POST message...
Please help..

This is a dev tool only, it's not actually part of your application. I suggest you read this intro which also tells you how to disable the feature.

Related

WindowsAuthentication on ASPNET MVC 3 not working (IsAuthenticated always false)

I'm trying to enable Windows authentication (setting windows mode on authentication) on a huge legacy ASPNET MVC 3 Application, but it isn't working and I can't find why; the Request.IsAuthenticated is always false. The app is very huge and has a lot of personalization with its own authentication and authorization system, but it uses the standard mechanisms of ASPNETMVC to override them (OnAuthorize). I've tried with empty controllers without "personalization" but it doesn't work neither.
I don't know how to start to write here all configuration so, I'm expecting for a genius who could point me to what is wrong...
I've tried too on a sampe new ASPNETMVC3 (from VS2010 templates) and it works fine; I would try to set every thing of my app on this one slowly to try to reproduce if I didn't found any solution before.
--- UPDATE ---
I've copied the web.config and global.asax of template project and it's not working yet. I've added the event WindowsAuthentication_OnAuthenticate on both projects and only enters on the demo project. I can't undersand how, where or why the ASPNET flow is broken.

Using Razor Templates Stored in Razor Class Library 3.0 (RCL) Without AspNetCore Web Application

I am using Razor templates (cshtml) to build HTML for use in emails. While I can get this all to work and I can send email from a ASPNetCore 3.0 web application I want to actually send email from another process which is NOT a web application. Ideally I would like to queue email, which can be triggered from any number of backend processes, and then send those from a timer like service which runs as a windows service or possibly a back-end worker running in Azure via something like Functions.
Is there any way to leverage razor templates from within a RCL in a .NetCore console or other application which is NOT hosted in AspNetCore??
I think there isn't a way to do this i am sry. :(
If I understand your question correctly, you can use RazorEngine, which I used in .NET Framework 4.6.2 Class Library. There is a .Net Core Nuget as well.
I referenced such Class Library projects from Console Applications, Windows Services and Azure Cloud Services (Worker Roles).
In my setup, I had to mark Razor files as Content so they are copied over to the bin folder. Also, it got more complicated if library is referenced by another library and then that library is used; content did not get copied over or it got flattened out (all razor views ended up in the root of the bin folder vs following directory structures), for which there is a fix by editing project file and adding your own copy build tasks. Or I had to embed razor views into DLL.
There might be improvements to this in recent years, as I said I used RazorEngine few years back. And it might be different in .Net Core RCL as well, but I believe it is possible.
Nowadays, I am using 3rd party services like SendGrid or MailJet. For me, using them avoids majority of the above issues and offers better insight into emails/templates/campaigns to Marketing and other non-tech users. They can edit and modify templates to their liking without (m)any code deployments.
You have to run the code through ASP.net core engine so that Razor code get converted into html.
Otherwise use simple html template.

How to debug MVC web app with rest api controller backend? [duplicate]

In VS 2012, I am attempting to create an MVC 4 web application with jQuery calls to a Web API project. (Other devs will be consuming the API with our current, native app, and probably adding to the API in the future.) So I have one project that is the Web API, and another project that is the MVC 4 website. I can only set one of them to run, and they use localhost:xxxxx.
How do I debug changes to both? For example, let's say I add a new API path /api/customer/get and then a new jQuery ajax call to that path and do something with the resulting JSON. I've changed code in both projects and want to follow it end-to-end; how do I launch both? How do I debug both?
Just to be clear, the MVC app isn't making server-side calls to the API, I'm using MVC mostly to be able to easily use bundling, minification, and (hopefully) pre-compiled Handlebars templates in .NET; the API calls are coming from jQuery. As I am still relatively new to these technologies, alternate suggestions are welcome.
Thank you in advance.
I had the same problem and have found a solution from here:
forums.asp.net
The fix is to do the following:
In your solution file, click properties go to the Startup project node (if it is not already selected)
Next select Multiple startup projects. Select your website and your webservice and in the Action column make sure both of them have "Start" selected.
Now when you debug your website and put a break point in your webservice, it should hit the break point.
Coming late to the party but in case anyone else is looking for a solution, this is what was best for me: Set the Api project up to be the starting project (I needed to limit to one startup so that I could flip between browsers more easily). After firing up the service project, right click on the web/ui project and select debug, start new instance. You'll have both running and you'll seamlessly step from web to api.
I had a similar problem with my web api project. My solution consisted of an angular front end with 2 web api projects on the backend. One web api project handled "authorization" and the other handled "resources". I used the following tutorial by Taiseer Joudeh as a starting point:
http://bitoftech.net/2014/09/24/decouple-owin-authorization-server-resource-server-oauth-2-0-web-api/
Breakpoints worked on the "authorization server"... but not on the "resource server". I compared the packages from the two projects to see what was different. Once I added "Microsoft.AspNet.WebApi.Cors" to the "resource server" project, the breakpoints starting working.

How to publish an ASP.NET MVC website

I've a site that I'd like to publish to a co-located live server. I'm finding this simple task quite hard.
My problems begin with the Web Deploy tool (1.1) giving me a 401 Unauthorized as the adminstrator because port :8172 comes up in the errors and this port is blocked - but the documentation says "The default ListenURL is http://+:80/MsDeployAgentService"!
I'm loathe to open another port and I've little patience these days so I thought bu66er it, I'll create a Web Deploy package and import it into IIS on the server over RDP.
I notice first that Visual Studio doesn't use a dialog box to gather settings, or use my Publish profiles but seems to use a tab in the project properties, although I think these are ignored when importing the package anyway?
I'm now sitting in the import wizard with Application Path and Connection String. I've cleared the conn string as I think this is for some ASP stuff I don't use but when I enter nothing in the Application Path, the wizard barks at me saying that basically I'm a weirdo because most people publish to folders beneath the root site.
Now, I want my site to be site.com/Home/About and not site.com/subfolder/Home/About and I think being an MVC routed site that a subfolder will introduce other headaches. Should I go ahead and use the root?
Finally, I also want to publish a web service to www.site.com/services/soap which I think IIS can handle.
While typing this question, Amazon have delivered my IIS 7 Resource Kit, and I've been scouring the internet but actually I'm getting more confused.
Comment here seems to show consensus opinion that Publish isn't for production sites and that real men roll their own.
ASP.NET website 'Publish' vs Web Deployment Project
...I guess this was pre- Web Deployment Tool era?
I'm going to experiment on a spare box for now but any assistance is welcome.
Luke
UPDATE
The site was imported (to the root) manually with Web Deploy and it worked. If you get the error "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' " its because your app pool is 4.0 and should be 2.0.
If you are using VS 2010, may I recommend Scott Hanselman's Web Debloyment Made Awesome?
http://www.hanselman.com/blog/WebDeploymentMadeAwesomeIfYoureUsingXCopyYoureDoingItWrong.aspx
Even if you are using VS2008, there are nice concepts there that will probably help.
I've experienced the same frustration and trouble with this as well. Coming from a Java web background where we can package everything as a single WAR and toss it on the server, the deployment process with ASP.NET seems archaic.
I currently have a python script that uses FTP to transfer the needed files to my test instance on the remote server. I have another python script that transfers those files to my live site. These scripts are smart enough to take care of differences between some of the configuration files etc..
I've found it much easier than trying to setup permissions or using the Microsoft deploy tools.
Hi you can use filezilla software to upload

ASP.NET MVC Deployment Issues

HI am new to ASP.NET MVC and I am running into some issues trying to deploy a very simple site! I took the MVC Storefront (Kona), made some basic changes and now I would like to deploy it to a webserver! For testing, I just turned on IIS7 on my windows 7 desktop! I change the web projects settings to use local IIS and run it!
The first issue I get is the "Request is not available in this context"... To fix this I had to remove the HttpContext.Current.GetSiteUrl() in the global.asx.cs file! If I now run the app it works but I have no css? If I switch back to VS development server everything works great?
I can also swithc from integrated mode on IIS to classic which makes the css work but then I have no routing?
On IIS 7, HttpContext.Current is null in Application_Start because it isn't triggered by the first request anymore.
You can work around that issue by moving the code from Application_Start to Application_BeginRequest and add a flag to indicate if the application is already initialized (member of the Global class). When false, execute the code that uses HttpContext.Current and set the flag to true so subsequent requests don't execute that piece of code.
Doing what is said above fixed the css for me but adding this to
http://blogs.msdn.com/mikeormond/archive/2008/11/06/and-getting-asp-net-routing-up-and-running-in-web-applications-and-on-iis7.aspx
Fixed the routing for me.
Good luck took me long enough!

Resources