Guest User

Untitled

a guest
Mar 26th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. namespace TimeSlice
  2. {
  3. public class Startup
  4. {
  5. public Startup(IConfiguration configuration)
  6. {
  7. Configuration = configuration;
  8. }
  9.  
  10. public IConfiguration Configuration { get; }
  11.  
  12. // This method gets called by the runtime. Use this method to add services to the container.
  13. public void ConfigureServices(IServiceCollection services)
  14. {
  15. services.AddMvc();
  16. }
  17.  
  18. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  19. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  20. {
  21. if (env.IsDevelopment())
  22. {
  23. app.UseBrowserLink();
  24. app.UseDeveloperExceptionPage();
  25. }
  26. else
  27. {
  28. app.UseExceptionHandler("/Home/Error");
  29. }
  30.  
  31. app.Run(async context =>
  32. {
  33. Console.Write("got here");
  34. String course = "CS3705";
  35. int user = 8;
  36.  
  37. SqlConnection con = new SqlConnection("host;initial catalog = timeslice;user id=timeslice;password=********");
  38. string query = "Insert into COURSES (courseName, userId) Values ('" + course + "', '" + user + "')";
  39. SqlCommand comm = new SqlCommand();
  40. comm.Connection = con;
  41. comm.CommandType = CommandType.Text;
  42. comm.CommandText = query;
  43.  
  44. con.Open();
  45. comm.ExecuteNonQuery();
  46.  
  47. await context.Response.WriteAsync("Hello");
  48. });
  49.  
  50. app.UseStaticFiles();
  51.  
  52. app.UseMvc(routes =>
  53. {
  54. routes.MapRoute(
  55. name: "default",
  56. template: "{controller=Home}/{action=Index}/{id?}");
  57. });
  58. }
  59. }
  60. }
Add Comment
Please, Sign In to add comment