In my VS solution, there are 3 projects as below:
1) Bot2015
2) Bot2015_2 (Startup Project)
3) DB
Bot2015_2 is my Startup Project but whenever I try to test the Bot2015_2 bot application via emulator, it calls the Message Controller of the first project i.e. Bot2015 (that is the issue here). It should access the Message Controller of the start up project i.e. Bot2015_2. Even if I unload the Bot2015 and test the application, same thing is happening, it never calls the correct Message Controller i.e. of Bot2015_2.
Please help me on this!
Thank You.
Double check what port are you using to communicate with your emulator. This is what the emulator use to communicate with your controllers.
To specify a port for a Web application project that uses IIS Express
In Solution Explorer, right-click the name of the application and then select Properties.
Click the Web tab.
In the Servers section, under Use Local IIS Web server, in the Project URL box change the port number.
To the right of the Project URL box, click Create Virtual Directory, and then click OK.
In the File menu, click Save Selected Items.
To verify the change, press CTRL+F5 to run the project.
The new port number appears in the address bar of the browser.
You can check more info here: MSDN
Related
I am trying to test the possibility to convert all my WCF service to WebAPI but so far it's a mess. WCF is easy because you create a default project and add 1 or 2 sample method that return anything then add as a service by using the http address and it works out of the box.
On WebAPI you add connected service and type the address and it throw errors so obviously out of the box it has errors and is missing stuff to actually work.
My question is what is missing to WebAPI made with .NET6 to be able to be connected to ?
Following Microsoft example what i should do is to run the service obviously. Then use the path of the json file generated by swagger and input that in the URL of the connected services, give it a namespace and a classname and your good to go.
Step 1 : Running the service
This works i can call the basic 3 method i made for test purpose that return string, List<string> and List<List<string>> and i can execute the "tryout" button and they output everything that it needs
Step 2 : Copy the json file path provided by Swagger
I assumed that this url is good by default. I can click it and i see the definition which seems good.
Step 3 : Create and empty console app and add the connected service
When adding the connected service i pick OpenAPI as it's the only option anyway.
Then it asks for File or URL that i put my value form the service that is running. In this case this is : https://localhost:44341/swagger/v1/swagger.json. I then choose the namespace of WebTest1 and classname of WebTest2 as i dont care and click next
Step 4 : Configuration progress
This is where i have the error which is where i see that the service that can actually run cannot be connected to
Checking project for required NuGet packges... Downloading service
reference from https://localhost:44341/... ErrorFailed adding service
reference(s). Failed to download metadata file from :
https://localhost:44341/.
I finally figured out the temporary fix. I was also able to copy this project over to a colleague and the issue is the same. The problem lies into Visual Studio defaulting for some reason on the debug option of IIS Express which does properly run the service when you press F5 and your browser open normally and you can test things out. The problem is that when you project runs under IIS (actually configured like it would be the real deal) or IIS Express (the only IIS option in the debug setting) you cannot from another application connect to that service.
However if you switch the debug option to the project name and run your WebApi with that instead it also works as expected from the browser that it open but you now can actually add that service from another application without any error.
Personally i have a third option which is WSL which i "guess" is the linux sub system i can't tell as this crash when i try to start and there is no help for the UI of Visual Studio to help understand these menu options.
Now i still have a problem to attach to one running in a real IIS which is probably linked to the same reason why IIS Express debug doesn't work. So i now know that the base code works and now it's an issue of finding why the default doesn't let other application consume from IIS / IIS Express.
For reference purpose this is the debug menu in question where the IIS Express option is not working but selecting the project name like pointed out on the picture actually works.
I've got a web application for our office use only. In my office I've got 12 computer and want to install one pc and access via web browser from all computers. I can run web application on visual studio but couldn't find a proper way for all computers and kinda new in this area.
I would like to access on browser like "myapp.com" or localhost something else. Is that possible to give specific name and access even on mobile phones?
Thanks in advance for all suggestions.
You can host your application using IIS. IIS can be setup in any machine.
Steps :
Install IIS
Open IIS manager by entering inetmgr in Run(win+R)
Add website by browisng to its location to the published website location. (Hope you know how to publish a website in visual studio)
Edit the web config file to configure the sql server credentials(Sql db could be hosted separately or in the same machine)
Right click the website in IIS Manager and click start.
Click browse to view the website
You could either access the site by localhost:portnumber or by specifying IP:port number in settings of the website in IIS manager
You can access the website from mobile or external devices if you select public IP for your website. Incase you're connected to a local network, then the website could be accessed only from within your work place. Discuss with your network admin about exposing your server to public by providing a public IP address, if you're on local network.
Feel free to revert if you have more doubts.
I wanted to create and use a Web Service in VisualStudio2010.
So, all I did was:
File->New Project->(.Net Framework3.5)Asp.NET WebService Application.
The hello world source page opened, I set visual studio development server, and the desired port, from properties and then I hit run. The problem is the page it is not opening. It is a connection problem or something.
Can you please tell me what do I have to do to make this webservice to run??
There are no error reports in visual or anything. It is just there is no display.
File->New Project->(.Net Framework3.5)Asp.NET WebService Application.
1.dont setup startup page.
2.run your webservice using green icon .
3.directory will be listed in browser.
4.select .svc file.
5.Your service is ready to execute.
I have written a WCF web service (not a web site, just JSON over HTTP) intended to run in Azure. I need to write tests for it.
I know how to do this, but it seems amateurish:
Run the web service,
Copy the root URL (e.g. http://localhost:81/)
Apply the root URL to my test project,
Run the test project.
I would like to be able to do this:
Hit F5
--> web service starts running
--> tests start running, automatically finding where IIS decided to run the service.
Is there a way?
There are 2 ways you can do this. Since you're using Windows Azure I assume you're using the emulator. Using the emulator means that the RoleEnvironment is available and you can get a list of roles, their instances, and their endpoints that are available.
var endpoint = RoleEnvironment.Roles["WebRole1"].Instances.First().InstanceEndpoints["Endpoint1"];
var siteUrl = String.Format("{0}://{1}", endpoint.Protocol, endpoint.IPEndpoint);
This code will get the role named WebRole1, get the first instance on this role (you could use this to test if your web service supports load balancing) and get the InstanceEndpoint. The instance endpoint will give you all info you need like protocol (http/https) and the IP/port (these are things you configure in the ServiceConfiguration).
Note: This also works for processes running outside the emulator (like your test project). The only thing you'll need to do is reference Microsoft.WindowsAzure.ServiceRuntime.
Besides that you can also try to use the ServerManager class to find the current sites running in IIS, but I don't think this will work if you're running in IIS Express (which is also possible if you're working with Azure).
Fix the port number of the WCF project: go to the properties of your project, set "use dynamic ports" to false then specify a fixed number, for example 81.
Specify multiple startup projects in your solution: right mouse button on solution: select "set startup projects", then check the radiobutton "multiple startup projects", include your WCF service project in the startup list.
I hope this meets your needs...
I have one asp.net simple page, on button click I'm trying to start one process(.net console application) but I'm having access denied exception..
If the process is simple windows applications like notepad.exe, or anything else "not .net assembly" the code works...
The problem only happens when I'm running the code from IIS, but from Visual Studio it works.
Where is the .net console application located?
The 'Access Denied' message indicates that it's probably located somewhere that the user the application pool is running as doesn't have access to.
If you run Internet Information Services Manager (from Control Panel > Administrative Tools) and navigate to Internet Information Services > MACHINE NAME (local computer) > Application Pools in the treeview at the left of the window, you'll see a list of application pools (processes that IIS uses to run your website). Then:
Expand each one in turn until you find the one that has your virtual directory listed underneath it.
Right-click on the one application pool that's the correct one (probably DefaultAppPool) and choose Properties
In the window that appears go to the "Identity" tab
The window will tell you what user the website is running as, you need to make sure that user has permissions to your console application, or, change the user to one that already does.