question

Elado avatar image
0 Votes"
Elado asked YijingSun-MSFT commented

How to add a [WebMethod] file for WebService1.asmx ?

I have a project with server side in C# and SQL Server
I'm connected to the SQL Server and want to pass it parameters to a table.

How do I open a WebMethod file ? I can't find it
neither a WebService project.

119529-webmethod.png

ASP.NET Core Web API - is not the right way , because I figured that I can't send parametrs to the SQL from the browser.


windows-serverdotnet-csharpdotnet-aspnet-general
webmethod.png (20.9 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This came built in with the webMethod -
I managed to open new project ASP NET Empty Web Site with --> asmx

can't load image, but here - https://im.ge/i/L6VQh
L6VQh


0 Votes 0 ·

How do I open a WebMethod file ? I can't find it

Usually there is a code behind file WebService1.asmx.cs. Just double click the WebService1.asmx file. You should see the code behind in the editor. If you see a WebService directive then my best guess is you copied the file from another project???

 <%@ WebService Language="C#" CodeBehind="~/App_Code/WebService.cs" Class="WebService" %>

ASP.NET Core Web API - is not the right way , because I figured that I can't send parametrs to the SQL from the browser.

Simply not true. Passing parameter to Web API and SQL is covered in every beginning level tutorial. However, you must understand HTTP fundamentals. Mainly GET and POST actions. HTTP GET submits parameters in the URL. HTTP POST submits parameters in the HTTP message body.

HTTP GET vs POST


0 Votes 0 ·

1 Answer

DuaneArnold-0443 avatar image
0 Votes"
DuaneArnold-0443 answered YijingSun-MSFT commented

There is no such thing as a Webmethod file. You can add a classname.cs to the project the class can contain WebMethod(s) in the class.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This came built in with the webMethod -
I managed to open new project ASP NET Empty Web Site with --> asmx

can't load image, but here - https://im.ge/i/L6VQh
L6VQh


0 Votes 0 ·

Maybe you need to find some better tutorials.

0 Votes 0 ·

Hi @Elado ,
[WebMethod] isn't a type of file, it's an attribute you apply to methods in your service to mark them as available for calling remotely. Once you've added the attribute to a method, it will appear in the list of methods exported in the service's webservice definition.
Attaching the WebMethod attribute to a Public method indicates that you want the method exposed as part of the XML Web service. If you need to add it, you could manual input it on your public method.
Best regards,
Yijing Sun

0 Votes 0 ·