This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomeController : Controller { | |
public async Task<ActionResult> Index() { | |
HttpClient client = new HttpClient(); | |
var result = await client.GetAsync("http://webapiasync.tugberk.me/api/cars"); | |
doWork(); | |
return View(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<T> Query<T>(this DbContext @this, System.Linq.Expressions.Expression<Func<T, bool>> predicate = null) | |
where T : class { | |
var query = (predicate != null) ? @this.Set<T>().Where(predicate) : @this.Set<T>(); | |
var cmd = new SqlCommand(); | |
cmd.Connection = (SqlConnection)(@this.Database.Connection); | |
//gets the generated t-sql | |
cmd.CommandText = query.ToString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Target Name="Compile" DependsOnTargets="Init"> | |
<MSBuild Projects="@(MainSolutionfile)" Targets="Rebuild" Properties="OutDir=%(OutputDir.FullPath);Configuration=$(Configuration)" /> | |
</Target> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="/api/values" method="post"> | |
<input type="text" name="value" /> | |
<input type="submit" value="Submit" /> | |
</form> | |
<form id="fooForm" action="/api/values" method="post"> | |
<input type="text" name="value" /> | |
<input type="submit" value="Submit" /> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebApiApplication : System.Web.HttpApplication { | |
protected void Application_Start() { | |
//... | |
GlobalConfiguration.Configuration.MessageHandlers.Add(new RemoveServerHeaderMessageHandler()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CarsController : ApiController { | |
public string[] Get() { | |
var cars = new string[] { | |
"Car 1", | |
"Car 2", | |
"Car 3" | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Request: | |
---------------------------------------------------------------------------- | |
GET http://localhost:49207/api/cars HTTP/1.1 | |
User-Agent: Fiddler | |
Host: localhost:49207 | |
Accept: application/json | |
Response: | |
---------------------------------------------------------------------------- | |
HTTP/1.1 200 OK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Net; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
namespace ResponseEntityProcessor.Handlers | |
{ | |
/// <summary> | |
/// Wraps an inner <see cref="HttpContent"/> and forces the content to be written |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523 | |
function guidGenerator() { | |
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); | |
return v.toString(16); | |
}); | |
} |