Willy
Willy

Reputation: 10660

C# Web Service: Getting product name assembly and machine name where it is executed

I have a Web Service in C# that is published to a server on IIS.

In this web service I build a connection string using some parameters.

There are two, "Applicacion Name" and "Workstation Id" that I would like to set them with assembly product name and machine name where web service is executed. So I do that as below:

In Win forms apps I use these values but are they correct when talking about web services? I mean, Are these values extracted in a different way in web services?

Also to avoid using System.Windows.Forms namespace is there any other way to obtain web service application name?

By Application name I mean the product name that appears from visual studio ide when you go to project properties => Application => Assembly information button => Product Name field.

Upvotes: 0

Views: 352

Answers (1)

Shuvra
Shuvra

Reputation: 199

You can store the values in app.config file of Web service.

Hi, You can store the values in app.config file of Web service.
<configuration>
  <appSettings>
    <add key="ApplicationName" value="ValueApplicationName" />
    <add key="WorkstationID" value="ValueWorkstationID" />
  </appSettings>
</configuration>
When you open the application that connects with web service, The web service can pass this value to the application. Use System.Configuration to read value from config file: 
string AppName = ConfigurationManager.AppSettings["ApplicationName"];

Upvotes: 2

Related Questions