[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class SmartWebService : System.Web.Services.WebService
{
[WebMethod(enableSession: true)]
public string GetLastWeekVisits()
{
string strResult = string.Empty;
DateTime dteCurDate = Utilities.DateInfo.GetCurrentServerDateTime(Singleton.StaticConnectionString);
DateTime dte7DaysAgo = dteCurDate.AddDays(-7);
string strMinDate = Utilities.DateInfo.GetPersianDate(dte7DaysAgo);
string strMaxDate = Utilities.DateInfo.GetPersianDate(dteCurDate);
DataTable dtData = HelperClass.GetVisitsByDates(strMinDate, strMaxDate);
if (dtData != null)
{
strResult = HelperClass.ConvertDataTableToJson(dtData);
}
return strResult;
}
}
This works when i run from this url and click on my web method, then invoke it :
http://localhost:9748/SmartWebService.asmx
The above action redirect to this url & it works correctly :
My guess is that the URL your trying to reach directly on a new browser is of a temporary virtual server created by Visual Studio, so when you try to access it directly, via the temporary port, such virtual IIS application is non existant.
Try creating an application on your default website on your local IIS, place the service there, and then access it like http://localhost/myIISApplication/SmartWebService.asmx/GetLastWeekVisits where myIISApplication is whatever name you set on IIS.
Member
35 Points
270 Posts
Call asmx webservice redirects to my custom 404 error page!
Jun 27, 2020 08:03 AM|hamed_1983|LINK
Hi
in my asmx file, i have a web method as follow :
This works when i run from this url and click on my web method, then invoke it :
The above action redirect to this url & it works correctly :
But when i copy/paste above url into new webBrowser tab page, i'm facing my custom error 404!
I've also do a lot of search on the web & found some links such as this, but does not works for me!
Can anybody help me where is the problem & how to solve it?
Thanks in advance
Participant
1226 Points
857 Posts
Re: Call asmx webservice redirects to my custom 404 error page!
Jun 28, 2020 12:19 AM|0belix|LINK
Hi hamed,
My guess is that the URL your trying to reach directly on a new browser is of a temporary virtual server created by Visual Studio, so when you try to access it directly, via the temporary port, such virtual IIS application is non existant.
Try creating an application on your default website on your local IIS, place the service there, and then access it like http://localhost/myIISApplication/SmartWebService.asmx/GetLastWeekVisits where myIISApplication is whatever name you set on IIS.
Member
35 Points
270 Posts
Re: Call asmx webservice redirects to my custom 404 error page!
Jun 28, 2020 08:01 AM|hamed_1983|LINK
Sorry, but i don't think!
Please take a look at this sample project.
Member
35 Points
270 Posts
Re: Call asmx webservice redirects to my custom 404 error page!
Jun 28, 2020 11:48 AM|hamed_1983|LINK
I found solution!
You must add the following configuration in your web.config :
Reference link.
Best regards ...