none
C# WCF IIS Visual Studio community communication error RRS feed

  • Question

  • I wrote a C# WCF service, then I installed it on to a service but when I Browse it, see this :

    and when I try to and add it as a web Reference it says : webMissingResource -webDiscoRefReport -Name cannot begin with '%' character, hexadecimal value 0x25. line 1, position 2. -webDiscoRefReport -webDiscoRefReport

    so something is wrong... the service worked in debug mode. here is my wed.cong :

    can anyone help ?

    Tuesday, November 28, 2017 5:20 AM

Answers

  • Given that IIS is serving .svc files as raw content files it doesn't look like ASP.NET is either installed in IIS or properly registered. When you installed IIS there is an option to install ASP.NET support. You need to install support for 4.5 if that is the version of .NET your service is trying to use. This is done using the option under Windows Features.

    If it is installed then you may need to reregister everything using aspnet_regiis. When IIS sees the .svc file it should return back the standard WCF page if ASP.NET is properly installed.


    Michael Taylor http://www.michaeltaylorp3.net

    • Marked as answer by Btb4198 Wednesday, November 29, 2017 12:00 PM
    Wednesday, November 29, 2017 3:03 AM
    Moderator
  • Hi Btb,

    Based on your description, this issue only exists under IIS. Are the published Service and Development Service in the same computer? Could you share us how you published WCF Service?

    I found you only have Bin Folder under BaileyF, if I add a new web application to IIS by setting path to my project, it will also contains “App_Data” and other folders.

    If you published the service to different computer, I suggest you follow link below to configure your WCF Service.

    # Configuring Internet Information Services 7.0 for Windows Communication Foundation

    https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/configuring-iis-for-wcf

    It would be helpful if you could share us your detail steps while publishing.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Btb4198 Wednesday, November 29, 2017 12:00 PM
    Wednesday, November 29, 2017 2:32 AM

All replies

  • <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" />
      </system.web>
      <!-- When deploying the service library project, the content of the config file must be added to the host's 
      app.config file. System.Configuration does not support config files for libraries. -->
      <system.serviceModel>
        <services>
          <service name="BaileyFritz_Service.Bailey">
            <endpoint address="http://ec2amaz-fn5n011/BaileyF/BaileyFritz_Service.Bailey.svc" binding="basicHttpBinding" contract="BaileyFritz_Service.IBailey">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8733/Design_Time_Addresses/BaileyFritz_Service/Service1/" />
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, 
              set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
              <!-- To receive exception details in faults for debugging purposes, 
              set the value below to true.  Set to false before deployment 
              to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="True" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    
    </configuration>
    

    Tuesday, November 28, 2017 5:21 AM
  • Do you mean it worked when using IISExpess with Visual Studio and it doesn't work using the real IIS? 
    Tuesday, November 28, 2017 12:46 PM
  • when I hit debug in Microsoft Visual Studio a client comes up and I can pull data:
    Tuesday, November 28, 2017 2:03 PM
  • The endpoint address in your config is incorrect. It is the base address from the IIS site that is hosting your app. For a single endpoint (minus mex) you can simply leave it blank. You shouldn't need the base address stuff at all.

    <system.serviceModel>
        <services>
          <service name="BaileyFritz_Service.Bailey">
            <endpoint address="" binding="basicHttpBinding" contract="BaileyFritz_Service.IBailey">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
        </services>
    
    Also make sure that you have configured the hosting site as an Application. Given that it is simply rendering the contents of the .svc file it looks like you might not have configured it as such. Select the folder in IIS and then right-click and select Convert to Application. Select an app pool (generally either a custom app pool (preferred) or the 4.0 app pool in integrated mode). Then browse to the URL again. Note that you should be able to go to the Content view of the site in IIS (right side) and then select your .svc file and select Browse to automatically open it in the browser on the server. You should then get a standard WCF page about the svcutil configuration.


    Michael Taylor http://www.michaeltaylorp3.net

    Tuesday, November 28, 2017 2:58 PM
    Moderator
  • I only had this option for app pools 

    Should I have more?

    Tuesday, November 28, 2017 10:12 PM
  • I changed my wed.confil file:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" />
      </system.web>
      <!-- When deploying the service library project, the content of the config file must be added to the host's 
      app.config file. System.Configuration does not support config files for libraries. -->
      <system.serviceModel>
        <services>
          <service name="BaileyFritz_Service.Bailey">
            <endpoint address="" binding="basicHttpBinding" contract="BaileyFritz_Service.IBailey">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, 
              set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
              <!-- To receive exception details in faults for debugging purposes, 
              set the value below to true.  Set to false before deployment 
              to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    
    </configuration>
    


    and now I got this error :

    Tuesday, November 28, 2017 10:26 PM
  • ok I fix that error but now I am just having the same problem again :

    I do not understand my code works in the debugger 

    here is my server code :

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.Text;
    using System.Timers;
    using System.Data.SqlClient;
    using System.Data;
    
    namespace BaileyFritz_Service
        {
        // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
        public class Bailey : IBailey
            {
            int counter = 0;
           public Bailey()
                {
                ConnectToDb();
                }
    
            SqlConnection conn;
            SqlCommand comm;
            SqlConnectionStringBuilder connStringBuilder;
    
            void ConnectToDb()
                {
                connStringBuilder = new SqlConnectionStringBuilder();
                connStringBuilder.DataSource = "(LocalDB)\v11.0";
                connStringBuilder.InitialCatalog = @"\WRESTLING.MDF";
                connStringBuilder.Encrypt = true;
                connStringBuilder.ConnectTimeout = 30;
                connStringBuilder.AsynchronousProcessing = true;
                connStringBuilder.MultipleActiveResultSets = true;
                connStringBuilder.IntegratedSecurity = true;
                string temp = @" Data Source=(LocalDB)\v11.0;AttachDbFilename='C:\Wrestling.mdf';Integrated Security=True";
                conn = new SqlConnection(temp);
                comm = conn.CreateCommand();
                }
            public List<string> School_lists()
                {
                List<string> Schoolname = new List<string>();
                Schoolname.Add("Catholic High");
                Schoolname.Add("College Park");
                Schoolname.Add("Cypress Ridge");
                Schoolname.Add("Jersey Village");
                Schoolname.Add("Klein Collins");
                Schoolname.Add("Klein Oak");
                Schoolname.Add("ST Johns");
                return Schoolname;
                }
            public List<Schedule> CypressRidge(string table)
                {
                try
                    {
                    List<Schedule> item = new List<Schedule>();
                    comm.CommandText = "SELECT * FROM " + table;
                    comm.CommandType = CommandType.Text;
                    conn.Open();
                    using (SqlDataReader reader = comm.ExecuteReader())
                        {
                        // while there is another record present
                        while (reader.Read())
                            {
                            Schedule temp = new Schedule();
                            temp.Id = Convert.ToInt32(reader[0]);
                            temp.Opponent = Convert.ToString(reader[1]);
                            temp.Site = Convert.ToString(reader[2]);
                            temp.Team = Convert.ToString(reader[3]);
                            temp.date = Convert.ToDateTime(reader[4]);
                            temp.TournamentName = Convert.ToString(reader[5]);
    
                            item.Add(temp);
                            // call the objects from their index
                            }
                        }
    
                    int returnValue = comm.ExecuteNonQuery();
                    return item;
                    }
                catch (Exception ex)
                    {
                    throw;
                    }
                finally
                    {
                    if (conn != null)
                        {
                        conn.Close();
                        }
                    }
                }
            public int InsertSchedule(string fristname, string lastname, string name, int Grade, int age)
                {
                counter++;
                try
                    {
                    comm.CommandText = "INSERT INTO Other VALUES(@Id,@FirstName,@LastName,@school,@Grade,@age)";
                    comm.Parameters.AddWithValue("@Id", counter);
                    comm.Parameters.AddWithValue("@FirstName", fristname);
                    comm.Parameters.AddWithValue("@LastName", lastname);
                    comm.Parameters.AddWithValue("@school", name);
                    comm.Parameters.AddWithValue("@Grade", Grade);
                    comm.Parameters.AddWithValue("@age", age);
                    comm.CommandType = CommandType.Text;
                    conn.Open();
                    return comm.ExecuteNonQuery();
                    }
                catch (Exception ex)
                    {
                    throw;
                    }
                finally
                    {
                    if (conn != null)
                        {
                        conn.Close();
                        }
                    }
                return 1;
                }
            public List<Schedule> nextmatch(DateTime time)
                {
                List<Schedule> templist = new List<Schedule>();
                List<Schedule> tempSchedule = new List<Schedule>();
                try
                    {
                    tempSchedule.Add(returnSchedule(time, "kopantherwrestling"));
                    tempSchedule.Add(returnSchedule(time, "CatholicHigh"));
                    tempSchedule.Add(returnSchedule(time, "CypressRidge"));
                    tempSchedule.Add(returnSchedule(time, "kleincollins"));
                    tempSchedule.Add(returnSchedule(time, "College_Park"));
                    tempSchedule.Add(returnSchedule(time, "JerseyVillage"));
                    tempSchedule.Add(returnSchedule(time, "STJohns"));
                    Schedule temp = tempSchedule[0];
                    for (int i = 0; i < tempSchedule.Count; i++)
                        {
                        if (temp.date > tempSchedule[i].date)
                            {
                            temp = tempSchedule[i];
                            }
                        }
                    for (int i = 0; i < tempSchedule.Count; i++)
                        {
                        if (temp.date.Date == tempSchedule[i].date.Date)
                            {
                            templist.Add(tempSchedule[i]);
                            }
                        }
                    }
                catch (Exception ex)
                    {
                    throw;
                    }
                finally
                    {
                    if (conn != null)
                        {
                        conn.Close();
                        }
                    }
                return templist;
                }
            private Schedule returnSchedule(DateTime item, string table)
                {
                comm.CommandText = "SELECT TOP 1 * FROM " + table + " WHERE " + table + ".Time > @CurrentDate ORDER BY " + table + ".Time";
                comm.Parameters.AddWithValue("@CurrentDate", item);
                //comm.Parameters.AddWithValue("@table1", table);
                comm.CommandType = CommandType.Text;
                conn.Open();
                using (SqlDataReader reader = comm.ExecuteReader())
                    {
                    // while there is another record present
                    while (reader.Read())
                        {
                        Schedule temp = new Schedule();
                        temp.Id = Convert.ToInt32(reader[0]);
                        temp.Opponent = Convert.ToString(reader[1]);
                        temp.Site = Convert.ToString(reader[2]);
                        temp.Team = Convert.ToString(reader[3]);
                        temp.date = Convert.ToDateTime(reader[4]);
                        temp.TournamentName = Convert.ToString(reader[5]);
    
                        temp.Name = Convert.ToString(table);
                        conn.Close();
                        comm.Parameters.Clear();
                        return temp;
                        // call the objects from their index
                        }
                    return null;
                    }
                }
            public string GetData(int value)
                {
                return string.Format("You entered: {0}", value);
                }
            public CompositeType GetDataUsingDataContract(CompositeType composite)
                {
                if (composite == null)
                    {
                    throw new ArgumentNullException("composite");
                    }
                if (composite.BoolValue)
                    {
                    composite.StringValue += "Suffix";
                    }
                return composite;
                }
           
            
            
            
            
            
            
            }
        }
    

    Tuesday, November 28, 2017 10:35 PM
  • Hi Btb,

    Based on your description, this issue only exists under IIS. Are the published Service and Development Service in the same computer? Could you share us how you published WCF Service?

    I found you only have Bin Folder under BaileyF, if I add a new web application to IIS by setting path to my project, it will also contains “App_Data” and other folders.

    If you published the service to different computer, I suggest you follow link below to configure your WCF Service.

    # Configuring Internet Information Services 7.0 for Windows Communication Foundation

    https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/configuring-iis-for-wcf

    It would be helpful if you could share us your detail steps while publishing.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Btb4198 Wednesday, November 29, 2017 12:00 PM
    Wednesday, November 29, 2017 2:32 AM
  • Given that IIS is serving .svc files as raw content files it doesn't look like ASP.NET is either installed in IIS or properly registered. When you installed IIS there is an option to install ASP.NET support. You need to install support for 4.5 if that is the version of .NET your service is trying to use. This is done using the option under Windows Features.

    If it is installed then you may need to reregister everything using aspnet_regiis. When IIS sees the .svc file it should return back the standard WCF page if ASP.NET is properly installed.


    Michael Taylor http://www.michaeltaylorp3.net

    • Marked as answer by Btb4198 Wednesday, November 29, 2017 12:00 PM
    Wednesday, November 29, 2017 3:03 AM
    Moderator
  • it is installed :

    Wednesday, November 29, 2017 3:23 AM
  • what do you mean by " eregister everything using aspnet_regiis"?
    Wednesday, November 29, 2017 3:24 AM
  • Re-register ASP.NET with IIS. but looking at your config again I don't believe it is a server issue.

    The behavior you're seeing is that IIS is seeing the .svc file as a regular content file and not sending it through the ASP.NET runtime. But going back to look at your original web.config it isn't all there. There should be quite a few more entries in there. Specifically it doesn't have anything to configure the IIS site in the system.webServer section. So it looks like IIS isn't configured properly in your config. When you created the WCF project did you select a WCF Service Application? At a minimum your web.config should include the following configuration so that the site runs with the managed pipeline.

    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="false"/>
      </system.webServer>
    Right now I suspect it is not running through the managed pipeline and that is why you're seeing the raw .svc file instead of the hosted WCF page.


    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, November 29, 2017 3:35 AM
    Moderator
  • Are the published Service and Development Service in the same computer? no they are not

    Could you share us how you published WCF Service?

    i click the published button in MVS and published it to a folder on my computer and than move that over to my server.

    ok I did the program two ways meaning I have two project files

    one an  WCF application and one an WCF library...

    I was using the file made by the WCF library

     

    Wednesday, November 29, 2017 3:44 AM
  • A WCF library cannot be run in IIS. You need to build it as a WCF app (which generates a library but that isn't the point here). Add the appropriate config entry I specified and see if IIS works now.

    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, November 29, 2017 3:59 AM
    Moderator
  • ok I restarted the server and when back to the WCF application and installed some more stuff and restarted the server again and now I got this :

    but I do not see all my functions 

    why?

    Wednesday, November 29, 2017 4:14 AM
  • Hi Bth,

    Your original issue related with accessing svc file has been resolved, I would suggest you mark the helpful reply as answer to close current thread.

    >>but I do not see all my functions 

    For this new issue, I would suggest you post a new thread, and then we could focus on this specific issue to share our suggestion.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 29, 2017 5:03 AM
  • That is the correct page. When you navigate to a WCF service all you get is the standard WCF help page which shows how to connect to the service using svcutil. There is no built in functionality to allow you to interactively test the WCF service from IIS or see any of its methods. To test it you'll either need to write code or use the WCF Test Client which is installed with VS.

    Note that you can navigate to the mex endpoint and/or wsdl but that is just going to return the XML.


    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, November 29, 2017 6:12 AM
    Moderator