How can I use the button tag with ASP.NET?

Although you say that using the [button runat=”server”] is not a good enough solution it is important to mention it – a lot of .NET programmers are afraid of using the “native” HTML tags… Use: <button id=”btnSubmit” runat=”server” class=”myButton” onserverclick=”btnSubmit_Click”>Hello</button> This usually works perfectly fine and everybody is happy in my team.

How to allow download of .json file with ASP.NET

If you want to manually add support to your site, you can just add the following to your web.config in the system.webServer section: <staticContent> <mimeMap fileExtension=”.json” mimeType=”application/json” /> </staticContent> This will add a “local” configuration under IIS. This does not work in IIS6, but does work in IIS7 and newer.

In ASP.NET, when should I use Session.Clear() rather than Session.Abandon()?

Session.Abandon() destroys the session and the Session_OnEnd event is triggered. Session.Clear() just removes all values (content) from the Object. The session with the same key is still alive. So, if you use Session.Abandon(), you lose that specific session and the user will get a new session key. You could use it for example when the … Read more

What is the difference (if any) between Html.Partial(view, model) and Html.RenderPartial(view,model) in MVC2?

The only difference is that Partial returns an MvcHtmlString, and must be called inside <%= %>, whereas RenderPartial returnsvoid and renders directly to the view. If you look at the source code, you’ll see that they both call the same internal method, passing a StringWriter for it to render to. You would call Partial if … Read more

What is limiting the # of simultaneous connections my ASP.NET application can make to a web service?

Most of the answers provided here address the number of incoming requests to your backend webservice, not the number of outgoing requests you can make from your ASP.net application to your backend service. It’s not your backend webservice that is throttling your request rate here, it is the number of open connections your calling application … Read more

Can I incorporate both SignalR and a RESTful API?

Take a look at the video from this blog post. It explains exactly how you can use WebAPI with SignalR. Essentially, Web API + SignalR integration consists in this class: public abstract class ApiControllerWithHub<THub> : ApiController where THub : IHub { Lazy<IHubContext> hub = new Lazy<IHubContext>( () => GlobalHost.ConnectionManager.GetHubContext<THub>() ); protected IHubContext Hub { get … Read more