Solved

Simple WebService + IIS

Posted on 2013-01-23
11
262 Views
Last Modified: 2013-03-07
Hello, I'm trying to make a very simple web service and deploying it with IIS so other machines in my network can access it. I know almost zero about web programming and can't figure out what's going wrong.

Here is my webservice code (the default):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 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 Service : System.Web.Services.WebService
{
    public Service () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
    
}

Open in new window


I created it into a Folder (Web Site1). When I try to run it from VS itself I get an error "[No relevant source lines]". When I publish it to "c:\Inetpub\wwwroot" and try to access it via IIS, i get an error "You are not authorized to view this page."

Am I missing a step here?

Thanks in advance.
0
Comment
Question by:toddinho
  • 3
  • 2
  • 2
  • +2
11 Comments
 
LVL 6

Expert Comment

by:esolve
Comment Utility
I suppose this is a web service file (.asmx)? For this to work properly it must be contained in a ASP.NET Web Application. This will not run in any other application type.

You should also ensure that IIS is setup correctly on your local machine if you're using this for testing. Also ensure that your site is configured properly.

 In order to test r-click on the asmx file and select -> view in browser. You should then see a page with the method definition or an wsdl description language.
0
 
LVL 25

Expert Comment

by:Rouchie
Comment Utility
The WebService technology has now been replaced by the Windows Communication Foundation (WCF).  Therefore (and I've only been learning this myself a few months) I would recommend not pursuing a WebService in the manner you are doing currently.

In VS you can start a new project, then select Templates > Visual Basic > WCF > WCF Service Application and this will give you the code you need which runs perfectly well from the VS debug button.

You can then adapt it to suite your requirements.
0
 
LVL 6

Expert Comment

by:esolve
Comment Utility
You can still use a normal webservice. We're still using it and have been using it for the past few years without any problems.

But I would agree with Rouchie WCF does have lots more benefits.
0
 
LVL 25

Expert Comment

by:Rouchie
Comment Utility
Cheers @esolve

@toddinho - the main benefit is the WCF provides much better reliability with newer technologies while fully supporting older ones.  This 'just works' facility is priceless when learning as a newbie.  You will probably want to upgrade your .Net framework to 4.5 though as part of this.
0
 
LVL 19

Expert Comment

by:Amandeep Singh Bhullar
Comment Utility
Try using aspnet_regiis command to register .net modules.
For details check the article
http://msdn.microsoft.com/en-us/library/k6h9cz8h(VS.80).aspx
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:toddinho
Comment Utility
Yeah, I'm pretty sure it's a permission problem in IIS configuration... I tried the WCF Application and it ran in VS, but when I published it into IIS wwwroot folder i still couldn't visualize it...

In authentication methods I have Anonymous Access ticked and "Allow IIS to control PAssword"

Any ideas how to fix this??

PS: I'm gonna give the WCF a try since i didnt really start to delevop in web service anyway =p
0
 

Author Comment

by:toddinho
Comment Utility
In the event logs i got the following error:

"Failed ti execute request because the App-Domain could not be created.
Error: 0x80131902"
0
 
LVL 10

Expert Comment

by:Monica P
Comment Utility
http://forums.asp.net/t/960370.aspx

try to create new application pool for this new website

TRy to assign default page for the website

Set the directory browsing settings enabled.

Check whether page is getting opened in IIS through browse option.

Which IIS version are you using?
0
 
LVL 10

Accepted Solution

by:
Monica P earned 500 total points
Comment Utility
Three ideas, all fairly basic.
1. Make sure you have the proper .NET frameworks installed.
2. Make sure you have your virtual directory set to the right framework.
3. Run this in the command line to make sure your IIS/.NET permissions are correct.

c:\windows\microsoft.net\framework\v2.0.50727\aspnet_regiis.exe -i
0
 
LVL 19

Expert Comment

by:Amandeep Singh Bhullar
Comment Utility
Have u tried my suggestion to register IIS ????
0
 

Author Comment

by:toddinho
Comment Utility
Ok, I used the aspnet_regiis.exe -i (from every framework fodler), but i got the same error...

Im runnning IIS 5.1, VS 2010, Framework 4.0 and Windows XP...

@AkilaPalanimuthu: I checked the forum you posted, I cant find the place in IIS 5.1 to add IIS_WPG permission. Also i Tried to activate Directory Browsing woth no luck.

I actually erased the default files from IIS, I'm trying to visualize the service directly by righ-clicking it and "Browse"...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now