Starting point of Azure WebApp - asp.net

I opened a new .Net Framework WebApp and I am using it with Azure.
At the very first point, when I run the App from Visual Studio, it opens the browser and shows the default page:
I was looking for a "main" class or method but could not find one. I am wondering where does it start from? how this thing works?
If added a new method for which I want to run together with the WebApp, where should I call it from ?

I am wondering where does it start from? how this thing works?
This is about how does asp.net webapp run.When the application starts up, it runs Global.asax’s Application_Start() method. In this method, you can add Route objects to the static RouteTable.Routes collection. These will be inspected later when each request is received. Each Route object defines a URL pattern to be matched and the controller to be used in this case.
For more detail about how the Asp.net webapp run, you could refer to this article and this one.
If added a new method for which I want to run together with the WebApp, where should I call it from ?
When you publish to azure and add a new method in a controller, you could call it like yourappname.azurewebsites.net/Controllername/methodname. It mainly depend on your Rounte, you could refer to this article.
Azure App Service Web Apps is a service for hosting web applications, REST APIs, and mobile back ends. You can develop in your favorite language, be it .NET, .NET Core, Java, Ruby, Node.js, PHP, or Python. Applications run and scale with ease on Windows-based environments.
With App Service, you pay for the Azure compute resources you use. The compute resources you use is determined by the App Service plan that you run your Web Apps on.

Related

Call a nodejs script from an asp.net Web API

We have a REST API currently built using ASP.NET Web API and it's hosted on Azure.
One of our methods needs to compile an email template using the MJML language. Only problem is that there isn't an asp.net compiler for MJML, it's written in Node.js and none of us here know anything about node except for having used it in gulp as part of our build process.
So I guess the question is, is there an easy way (preferably on Azure) to host the node script with an endpoint that can be called from our Web API and return the compiled template.
Just to be clear, I'm not asking how to use MJML or it's compiler, just how to host a script written in Node and easy send and receive data from it. To keep this inside of Azure would be a bonus.
Many thanks.

Calling WCF service from jsp page

I have created a WCF Service and published it to a Windows Server running IIS. In an asp.net web application, I can add a Service Reference to the WCF Service which exposes its methods which I can call. This all works fine.
I need someone who is running a jsp site to be able to call a method in my WCF Service. How can they do that? (I know absolutely nothing about jsp). Presumably they cannot reference my WCF Service within their application in the same way you can within a .net application.
The web services are totally platform independent. Therefore, someone writing in Java should have no problem calling a web service server, regardless if it was written using WCF or another platform. For example, here, here and here you could find some tutorials on how to build web service clients using java. This java code could be called from JSP pages.
If you want to quickly test your web service from the client side, you could use SoapUI. It's a web service client tool developed in java. I am sure you will find it useful.
Hope I helped!

Add reference to service within same project

I'm wondering if it is okay to add a reference to a web service within the same project (web application), i.e. I'm adding a reference in the same project where the service is defined.
The reason for doing so is because
Hosting the service becomes easier (gets automatically hosted when hosting the web app).
Invoking the service is done dynamically, i.e. the service url is fetched (from db) at run time and methods on that particular service are invoked. (this is a web app which is hosted on many domains. each app knows the service url of other apps (urls stored in db). since I have a reference to the service, I can change the url at runtime by updating the Url of the proxy and invoke it.)
Also, I'm not sure if this is the way to go about it. I have seen a lot of people suggest using WCF instead of a web service, but I don't see how I could accomplish the same thing with WCF.
There is already a question regarding this on SO - Add Service Reference to WCF Service within Same Project, but i don't think it is valid for my situation.
If the service is already in your project, you can use it directly without requiring a web service proxy.
After all, Web services are for exposing your application functionality to the outside world and not to other parts of your system.

Create one big web project or split some features into web services?

At what point (if at any) does it make sense to take some of the features of a .NET web application and split them into separate web services?
For example, we have a very large web application that also calls a series of long running operations (our core business logic). We also have a dll with client-specific custom features that is called directly from the web project. Sometimes we need to move very quickly to change these client functions, often in hours.
However, if we make a change to the client-specific features (or an emergency change to the core features) and publish a new project, then it would kick all the users out the system as the app restarts. It would seem like there's a better way ... but I'm not sure what it might be ...
First of all, it makes sense to remove everything from the web project that is not involved with the UI. Put that in separate class libraries.
Do not create web services unless some other application will be calling them. Simply placing the code into separate projects will be enough. Web services should only be created if they are a requirement.
I think it makes sense to create service app (not like Web Service, but more like Windows Service). You could communicate between your webapp and service app using Message Queue.

.NET and webservices: how?

Im trying to make a webservice in ASP.NET and get the data in a Smart Device Application.
I have the standard HelloWorld webservice and i wanna get the data in my application, but when i try to add a web reference to my project, Visual Studio can't find any webservices running. If i start the WebService in the WebService project and copy/paste the url to the "Add WebReference" in the Application project, Visual Studio finds the Webservice and i can use the InttilSence to find the HelloWorld Method (WebServiceClass.HelloWorld()) in the WebService. But when i then run the Application project the complier gives an error saying that it can't connect to the WebService.
How do i do this? How do i access a webservice in an Application project? Every tutorial or book i have read about the subject doesn't tell anything about how the webservice should i run. In my world the webservice project should be running before i can access it from another project or am i wrong?
Consider reading Rick Strahl's Creating Web Services with .NET and Visual Studio.
From there, you'll get the basics. You can build and deploy your XML SOAP web service.
Then you'll need to have your application use that web service as a 'Web Reference'. Start by "Add Web Reference".
(source: usaepay.com)
First, you should publish the web service to some server (even your own local IIS) rather than using the Visual Studio web server.
Then in your application, point to the correct URL wherever you published it when adding the reference.
While this is a bit low-tech, couldn't you create a web requrest from the Smart Device Application to hit the webservice directly? That would be my suggestion.
An example would be using the "WebRequest" Class.
It sounds like when you try to access the Web Service from your app, the service is not running (possibly because you're only running it in the Cassini server?).
The fact that you were able to generate the Web Reference means that at some point, the service was running and was able to generate the helper classes by examining the service.
I would do as David Stratton suggests and publish it somewhere where it can run while you are developing the Smart Device app (like your local IIS).
You might also take the opportunity to wrap the service call with some error handling - maybe catch the specific exception being thrown (System.Net.WebException?)

Resources