.net core requesting data from sql server

Bluestreak22 Source

I have the below controller

using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Data.SqlClient;
using System.Data;
using Microsoft.EntityFrameworkCore;
using CRUD.Models;

namespace CRUD.Controllers
    public class RequestDataController : Controller
        RequestInfoDAL requestInfo = new RequestInfoDAL();
        private readonly ClaimsDBContext _context;

        public RequestDataController(ClaimsDBContext context)
            _context = context;

        // GET: api/RequestData
        public RequestInfo Details(int Request)
            return requestInfo.GetRequestInfo(Request);

when I navigate to /api/requestinfo/details/7507373 I get redirected to the home page, instead of seeing the response that I set below in my data access layer

public class RequestInfoDAL
        string connectionString = "Server=WAUDEVSQL28;Database=ClaimsDB;Trusted_Connection=True;";
        public RequestInfo GetRequestInfo(int Request)
                RequestInfo RequestInfo = new RequestInfo();

                using (SqlConnection con = new SqlConnection(connectionString))
                    string sqlQuery = "SELECT Request, TrackNum, Comp, Cust, OrderNum, InvoiceNum, OpsStatus, OPSComments, pcdStatus" +
                                      "FROM [tbl RequestData] WHERE Request = " + Request;
                    SqlCommand cmd = new SqlCommand(sqlQuery, con);
                    SqlDataReader rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                        RequestInfo requestInfo = new RequestInfo();

                        requestInfo.Request = Convert.ToInt32(rdr["Request"]);
                        requestInfo.TrackNum = Convert.ToString(rdr["TrackNum"]);
                        requestInfo.Comp = Convert.ToInt32(rdr["Comp"]);
                        requestInfo.Cust = Convert.ToInt32(rdr["Cust"]);
                        requestInfo.OrderNum = Convert.ToInt32(rdr["OrderNum"]);
                        requestInfo.InvoiceNum = Convert.ToInt32(rdr["InvoiceNum"]);
                        requestInfo.OpsStatus = Convert.ToString(rdr["OpsStatus"]);
                        requestInfo.OPSComments = Convert.ToString(rdr["OPSComments"]);
                        requestInfo.pcdStatus = Convert.ToString(rdr["pcdStatus"]);

                return RequestInfo;


I am trying to have agents input the request number to receive info about it. I have no idea how to provide a request id from the form yet but i cant even get the response to work by manually routing to it. Can anyone help?



comments powered by Disqus