locked
Rest Web API shows records in localserver, but not in IIS RRS feed

  • Question

  • User388518 posted

    Hello, I am trying to use Rest web API , to retrieve data. When i am building and executing it using localserver, it is displaying the data. But, when i publish it and use IIS to access it does not show any data. and shows this

    "This XML file does not appear to have any style information associated with it. The document tree is shown below."

    i am already using the same API for the functions of fileupload and they are working. Its just the matter of database, whenever i have to access database,it showing me the error above(This error means that no data is fetched).

    Can you please help me with it? Thanks in advance

    Monday, September 28, 2020 7:05 PM

All replies

  • User395683 posted

    You are probably calling the appi with http header expection for text/xml instead of text/html ¿Could please show us the piece of code where you are calling the appi?

    Monday, September 28, 2020 7:56 PM
  • User388518 posted

    Actually,i tried both of them. But in both of the cases, when i build and run it shows data. But the same call on IIS site does not show any data.

    I have tried so many things that i on my wits end right now :(

    Monday, September 28, 2020 8:44 PM
  • User395683 posted

    how are you declaring your http function in the server appi?

    Monday, September 28, 2020 9:20 PM
  • User356956 posted

    You should have asked this on StackOverflow, this is not a Xamarin.Forms question. However, I doubt anyone can help you without seeing relevant parts of your code

    Monday, September 28, 2020 11:30 PM
  • User388518 posted

    Hi, This is my Webapi.config

    _public static void Register(HttpConfiguration config) {

            // Web API routes
            config.MapHttpAttributeRoutes();
    
    
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }_
    

    This is my function

    _public string getUserName(int intUserID) { string strName=""; try { SqlConnection objConnection = new SqlConnection(strConnectionString);
    SqlCommand objCmd = new SqlCommand("GetUserName", objConnection); objCmd.CommandType = System.Data.CommandType.StoredProcedure; objCmd.Parameters.AddWithValue("@UserID", intUserID);

                objConnection.Open();
                SqlDataReader objDataReader = objCmd.ExecuteReader();
    

    while (objDataReader.Read()) { strName =Convert.tostring(objDataReader["UserName"]);
    }
    objConnection.Close();

            }
            catch (Exception ex)
            {
    
            }
            return strName ;
        }_
    
    Tuesday, September 29, 2020 1:02 PM