Re: Minimal Web API code helper package

2023-10-30 Thread Greg Keogh via ozdotnet
>
> I think the package you are looking for is Carter
>
>
>
> https://www.nuget.org/packages/Carter
>
> https://github.com/CarterCommunity/Carter
>

Folks, some quick feedback. Carter wasn't quite as attractive as I guessed.
It adds too much of what I call "magic plumbing" and lots of fluent methods
for validation and authorisation that weren't of much use for me. I didn't
want to get married to another framework without a good reason, so I
skipped it and moved all my endpoint methods into a partial class:

static partial class Program
{
  public static void MapEndpoints(IEndpointRouteBuilder app,
WebApplicationBuilder builder)
  {
app.MapPost(...) { etc }
// etc
  }
}

I call  MapEndpoints(...) during program startup and it separates all that
code into a separate file, and for a good reason ... I use a T4 template to
generate about 1000 lines of repetitive app.mapxxx(...) calls into that
partial file.

*Greg K*
-- 
ozdotnet mailing list 
To manage your subscription, access archives: https://codify.mailman3.com/ 

Re: Minimal Web API code helper package

2023-10-18 Thread Greg Keogh via ozdotnet
>
> I think the package you are looking for is Carter
>
> https://www.nuget.org/packages/Carter
>
> https://github.com/CarterCommunity/Carter
>

Yes thanks, that looks familiar.

It doesn't look quite as *clever* as I recall, but I'll look into it
anyway. I tried something vaguely similar myself last year, but it's time
to revisit the issue and see how someone else tackled the matter.

*Greg*
-- 
ozdotnet mailing list 
To manage your subscription, access archives: https://codify.mailman3.com/ 

RE: Minimal Web API code helper package

2023-10-18 Thread Cameron Booth via ozdotnet

Folks, a couple of weeks ago I was watching a video where someone used a NuGet 
package in a minimal Web API project to change the plumbing slightly so that it 
was easier to code the endpoint methods. By default, the endpoint methods must 
be strictly coded and it's tricky to break them apart or make partial methods. 
The package I saw added some magic to make coding the endpoints easier, but I 
can't remember exactly how. I just remember thinking "that looks handy" and now 
I can't find it. Any idea what it might have been?

Greg Keogh


I think the package you are looking for is Carter

https://www.nuget.org/packages/Carter
https://github.com/CarterCommunity/Carter
This message contains privileged and confidential information intended only for 
the use of the addressee named above. If you are not the intended recipient of 
this message you are hereby notified that you must not disseminate, copy or 
take any action or place any reliance on it. If you have received this message 
in error please notify the sender immediately via return email. Any views 
expressed in this message are those of the individual sender, except where the 
sender specifically states them to be the views of the company.
-- 
ozdotnet mailing list 
To manage your subscription, access archives: https://codify.mailman3.com/ 

Minimal Web API code helper package

2023-10-18 Thread Greg Keogh via ozdotnet
Folks, a couple of weeks ago I was watching a video where someone used a
NuGet package in a minimal Web API project to change the plumbing slightly
so that it was easier to code the endpoint methods. By default, the
endpoint methods must be strictly coded and it's tricky to break them apart
or make partial methods. The package I saw added some magic to make coding
the endpoints easier, but I can't remember exactly how. I just remember
thinking "that looks handy" and now I can't find it. Any idea what it might
have been?

*Greg Keogh*
-- 
ozdotnet mailing list 
To manage your subscription, access archives: https://codify.mailman3.com/ 

Re: Testing Web API

2021-11-28 Thread DotNet Dude
Breakpoint at the start of test method in test project.
Start debugging test project.
Breakpoint in web api action method.
Right click on webapi project and go to Debug -> Start new instance.

When the api call is made, the breakpoint in the action method will get hit.

Give that a go. I do that in VS2019 and it is working.

On Sat, Nov 27, 2021 at 4:30 PM Greg Keogh  wrote:

> Howdy, I have a VS2022 solution containing a .NET 6 Web Api project and an
> MS Test project to drive it. You can't hit F5 and run both the web app and
> tests in the debugger at the same time.
>
> Web searches produce no useful suggestions other than using "dotnet test"
> from the command line while the web app is debugging (which works, but is
> just a workaround). I could run two VS instances at the same time, but that
> seems stupid (is it?).
>
> Has anyone got a technique for debugging this combination?
>
> *Greg K*
>


Testing Web API

2021-11-26 Thread Greg Keogh
Howdy, I have a VS2022 solution containing a .NET 6 Web Api project and an
MS Test project to drive it. You can't hit F5 and run both the web app and
tests in the debugger at the same time.

Web searches produce no useful suggestions other than using "dotnet test"
from the command line while the web app is debugging (which works, but is
just a workaround). I could run two VS instances at the same time, but that
seems stupid (is it?).

Has anyone got a technique for debugging this combination?

*Greg K*


RE: Web API HelpPage

2016-03-09 Thread Ian Thomas
On a tangent, but might be of interest to some: DocPreview, in the VS Gallery – 
similar to Resharper's XML documentation preview (but free, though Resharper is 
not pricey of course and does much more).

http://bit.ly/1U4wbfn 

Developed by Oleg Shilo, relies on the source code (not the assemblies), 
supports C#/C++, in active development this month (v1.0.30). 

 

Related (sort of) is immoDoc.NET

https://github.com/marek-stoj/ImmDoc.NET 

which is (quoting) – 

a command-line utility for generating HTML documentation from a set of .NET 
assemblies and XML files created by the compiler. It's developed in C#.

• Simple

• Light-weight

• Blazingly fast 

  • 10-20 times faster than VsDocMan

  • 20-25 times faster than Sandcastle

• Supports .NET Framework 2.0 and above

• Can generate HTML and CHM documentation

• Uses Mono.Cecil

 

Ian Thomas

Albert Park, Victoria 3206 Australia

 



RE: Web API HelpPage

2016-03-08 Thread Paul Glavich
We started using the WebAPI help package quite some time ago. We did some 
tweaks, it came out with an update, we updated, broke pretty much everything. 
We have since customised the crap out of it and are now pretty happy with it. 
There are some shortcomings but overall it is doing what we want and dev story 
is pretty clean. We absolutely advocate some manual content that augment the 
pure tech stuff tho.

 

You can see the result here https://api.saasu.com

 

We have made the call a little while ago to not worry about any future 
upgrades, or anything like that. It has enough customisation to not warrant the 
pain of breakage.

 

-  Glav

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On 
Behalf Of DotNet Dude
Sent: Wednesday, 9 March 2016 10:52 AM
To: ozDotNet <ozdotnet@ozdotnet.com>
Subject: Re: Web API HelpPage

 

 

On Wed, Mar 9, 2016 at 10:27 AM, Greg Keogh <gfke...@gmail.com 
<mailto:gfke...@gmail.com> > wrote:

Folks, just a heads-up ... I was looking for a way of auto-generating Web API 
documentation and I found THIS 
<http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages>
  from 2013, and there are similar articles all over the place, all a bit old. 
The advice on getting it going works after you add the Nuget package and make 
the tweaks. However: 

*   I had to manually alter the package code to read and merge multiple 
xmldoc files.
*   I cannot get the Request Formats to say anything but "Sample not 
available".
*   I cannot get the Additional Information column to display anything 
because my entity classes are in a portable library and can't have attributes 
applied to them.
*   All standard xmldoc tags in your comments are stripped back to empty 
strings in the web API help, meaning you can't have both API help and 
Sandcastle help for the same code with nice formatting and links.
*   Instructions on how to style the API help no longer work and it's all 
dull black and white.

 

So for simple API help it works, but the moment you want to customise or 
enhance anything it all goes to hell. I've wasted up to 4 solid hours trying to 
workaround all of the irritations I described. It's like someone had a great 
idea with this, but coded it like a high school project.

 

 

lol sound like every project I've inherited

 

Perhaps there are better tools, but a quick look at Swagger hints that you have 
to write almost all of the documentation and samples manually as JSON.

 

GK

 



Web API HelpPage

2016-03-08 Thread Greg Keogh
Folks, just a heads-up ... I was looking for a way of auto-generating Web
API documentation and I found THIS
<http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages>
from 2013, and there are similar articles all over the place, all a bit
old. The advice on getting it going works after you add the Nuget package
and make the tweaks. However:

   - I had to manually alter the package code to read and merge multiple
   xmldoc files.
   - I cannot get the Request Formats to say anything but "Sample not
   available".
   - I cannot get the Additional Information column to display anything
   because my entity classes are in a portable library and can't have
   attributes applied to them.
   - All standard xmldoc tags in your comments are stripped back to empty
   strings in the web API help, meaning you can't have both API help and
   Sandcastle help for the same code with nice formatting and links.
   - Instructions on how to style the API help no longer work and it's all
   dull black and white.


So for simple API help it works, but the moment you want to customise or
enhance anything it all goes to hell. I've wasted up to 4 solid hours
trying to workaround all of the irritations I described. It's like someone
had a great idea with this, but coded it like a high school project.

Perhaps there are better tools, but a quick look at Swagger hints that you
have to write almost all of the documentation and samples manually as JSON.

*GK*


Re: Web API Accept type

2015-08-18 Thread Greg Keogh

 I would provide two different methods. It's easier for you and easier for
 the end developers to understand.


In the end I sort of did that. It's best not to fight the system, so I
changed the method so that it simply returns a serialized object (a rather
complicated one), but no matter what format the request asks for I just let
the infrastructure pick the serializer and return it. I don't even tamper
with the shape of the JSON or XML that's returned. Yeah, *don't fight the
system* if you can avoid it! -- *GK*


Re: Web API Accept type

2015-08-18 Thread Davy Jones
I would provide two different methods. It's easier for you and easier for the 
end developers to understand.

Davy

Sent from my iPhone

 On 17 Aug 2015, at 23:56, Greg Keogh gfke...@gmail.com wrote:
 
 Folks, in Web API when you sent an object back in the response it's 
 automatically serialized as JSON or XML depending upon the Accept header. 
 This is great, but I have to cheat the system slightly and send back manually 
 tweaked XML only if the XML serializer is active. Rather than look at the 
 raw text of the request Accept headers, is there is more formal way of 
 knowing which serializer is active (if this means anything) -- GK


Re: Web API Accept type

2015-08-18 Thread Nelson
Hi Greg,


Sounds like this is what you want:
http://www.asp.net/web-api/overview/formats-and-model-binding/media-formatters

You can define your own media formatter to customise your response for
particular types


Regards,

Nelson Chan

On 18 August 2015 at 20:04, Greg Keogh gfke...@gmail.com wrote:

 I would provide two different methods. It's easier for you and easier for
 the end developers to understand.


 In the end I sort of did that. It's best not to fight the system, so I
 changed the method so that it simply returns a serialized object (a rather
 complicated one), but no matter what format the request asks for I just let
 the infrastructure pick the serializer and return it. I don't even tamper
 with the shape of the JSON or XML that's returned. Yeah, *don't fight the
 system* if you can avoid it! -- *GK*



Re: Web API Accept type

2015-08-17 Thread Bec C
Is you tweak of the xml generic, ie. will happen to every xml response?
If so I'd imagine the method would be to override the default xml
serializer (or implement some interface) and tell web api to use your one
instead of the default. Testing which one is active by any means just seems
hacky. Or perhaps I've misunderstood

On Tue, Aug 18, 2015 at 7:56 AM, Greg Keogh gfke...@gmail.com wrote:

 Folks, in Web API when you sent an object back in the response it's
 automatically serialized as JSON or XML depending upon the Accept header.
 This is great, but I have to cheat the system slightly and send back
 manually tweaked XML only if the XML serializer is active. Rather than
 look at the raw text of the request Accept headers, is there is more formal
 way of knowing which serializer is active (if this means anything) --
 *GK*



Web API and https timeout

2015-08-07 Thread Greg Keogh
Folks, I've put a Web API project (created by the VS2015 Framework 4.5
wizard) on my server. I've got two applications pointing to the folder with
the app files, one site is http scheme and the other site has a certificate
for https. The app responds and works okay with http, but it times out for
https.

http://www.gregsite.com.au/myapp/v3/blah?p=glop (works)
https://www.gregsite.net.au/myapp/v3/blah?p=glop (times out)

I'm quite disappointed, and I can't find any special config settings or
other tricks and web searches don't help as usual so far. Anyone got a clue?

*Greg K*


Re: Web API and https timeout

2015-08-07 Thread Bec C
Does the https one work on its own (http one removed or disabled)?

On Fri, Aug 7, 2015 at 4:30 PM, Greg Keogh gfke...@gmail.com wrote:

 Folks, I've put a Web API project (created by the VS2015 Framework 4.5
 wizard) on my server. I've got two applications pointing to the folder with
 the app files, one site is http scheme and the other site has a certificate
 for https. The app responds and works okay with http, but it times out for
 https.

 http://www.gregsite.com.au/myapp/v3/blah?p=glop (works)
 https://www.gregsite.net.au/myapp/v3/blah?p=glop (times out)

 I'm quite disappointed, and I can't find any special config settings or
 other tricks and web searches don't help as usual so far. Anyone got a clue?

 *Greg K*



Re: Web API and https timeout

2015-08-07 Thread Bec C
On Fri, Aug 7, 2015 at 5:19 PM, Greg Keogh gfke...@gmail.com wrote:

 Does the https one work on its own (http one removed or disabled)?


 They are completely independent, in different sites and different app
 pools, they only share the executable files folder (and I know the
 permissions are okay). The https one times out under all experiments I've
 run so far. I'm really surprised because REST style services and projects
 are relatively simple compared to WCF services where I've previously had to
 tweak the config file for https or http (which took hours of research!). I
 expected it to just GO! -- *GK*


I'd just start with the https one alone and get that working just to ensure
it has nothing to do with the sharing of files. If it doesn't work alone
then https isn't configured correctly. Sorry not clear if you've already
tried this.
Also I think there is a enableSSL or similar somewhere in the project
properties in case you've missed it.


Re: Web API and https timeout

2015-08-07 Thread Greg Keogh
OK FOLKS! Those of you who are sys admins don't laugh at what I just found,
by accidentally noticing that all of my web sites where slowly vanishing
throughout the afternoon...

Around 11am this morning I finished migrating 6 of my domains from one
provider to another. I set the DNS A records for all domains to point to my
home server's IP address. However, I transposed two digits of the address
and as a result, all domains slowly vanished as the records were propagated
around the globe. That's certainly why my https test failed, then an hour
later the http test failed (as the domain vanished).

At 17:30 all my domains were invisible, so I just put the correct IP back
in all of them. Now I wait and maybe later tonight I'll find that my REST
API is working as I originally expected.

Amazing eh?! -- *Greg K*

On 7 August 2015 at 17:35, Bec C bec.usern...@gmail.com wrote:


 On Fri, Aug 7, 2015 at 5:19 PM, Greg Keogh gfke...@gmail.com wrote:

 Does the https one work on its own (http one removed or disabled)?


 They are completely independent, in different sites and different app
 pools, they only share the executable files folder (and I know the
 permissions are okay). The https one times out under all experiments I've
 run so far. I'm really surprised because REST style services and projects
 are relatively simple compared to WCF services where I've previously had to
 tweak the config file for https or http (which took hours of research!). I
 expected it to just GO! -- *GK*


 I'd just start with the https one alone and get that working just to
 ensure it has nothing to do with the sharing of files. If it doesn't work
 alone then https isn't configured correctly. Sorry not clear if you've
 already tried this.
 Also I think there is a enableSSL or similar somewhere in the project
 properties in case you've missed it.



Re: Web API and https timeout

2015-08-07 Thread Bec C
Haha classic

On Friday, 7 August 2015, Greg Keogh gfke...@gmail.com wrote:

 OK FOLKS! Those of you who are sys admins don't laugh at what I just
 found, by accidentally noticing that all of my web sites where slowly
 vanishing throughout the afternoon...

 Around 11am this morning I finished migrating 6 of my domains from one
 provider to another. I set the DNS A records for all domains to point to my
 home server's IP address. However, I transposed two digits of the address
 and as a result, all domains slowly vanished as the records were propagated
 around the globe. That's certainly why my https test failed, then an hour
 later the http test failed (as the domain vanished).

 At 17:30 all my domains were invisible, so I just put the correct IP back
 in all of them. Now I wait and maybe later tonight I'll find that my REST
 API is working as I originally expected.

 Amazing eh?! -- *Greg K*

 On 7 August 2015 at 17:35, Bec C bec.usern...@gmail.com
 javascript:_e(%7B%7D,'cvml','bec.usern...@gmail.com'); wrote:


 On Fri, Aug 7, 2015 at 5:19 PM, Greg Keogh gfke...@gmail.com
 javascript:_e(%7B%7D,'cvml','gfke...@gmail.com'); wrote:

 Does the https one work on its own (http one removed or disabled)?


 They are completely independent, in different sites and different app
 pools, they only share the executable files folder (and I know the
 permissions are okay). The https one times out under all experiments I've
 run so far. I'm really surprised because REST style services and projects
 are relatively simple compared to WCF services where I've previously had to
 tweak the config file for https or http (which took hours of research!). I
 expected it to just GO! -- *GK*


 I'd just start with the https one alone and get that working just to
 ensure it has nothing to do with the sharing of files. If it doesn't work
 alone then https isn't configured correctly. Sorry not clear if you've
 already tried this.
 Also I think there is a enableSSL or similar somewhere in the project
 properties in case you've missed it.





Re: Web API and https timeout

2015-08-07 Thread Greg Keogh

 Does the https one work on its own (http one removed or disabled)?


They are completely independent, in different sites and different app
pools, they only share the executable files folder (and I know the
permissions are okay). The https one times out under all experiments I've
run so far. I'm really surprised because REST style services and projects
are relatively simple compared to WCF services where I've previously had to
tweak the config file for https or http (which took hours of research!). I
expected it to just GO! -- *GK*


Web API response formatting

2014-01-19 Thread Greg Keogh
Folks, what is the recommended way of letting the caller choose the format
of the response? I have a method that can return plain text or XML, so how
does the caller choose the one they want?

I could have a format= parameter on the method call (Rackspace do that),
or is it better to inspect the Accept header and obey it? Or something else?

Greg K


Re: Web API response formatting

2014-01-19 Thread Dave Walker
Accept header is the norm

On 20 January 2014 15:03, Greg Keogh g...@mira.net wrote:

 Folks, what is the recommended way of letting the caller choose the format
 of the response? I have a method that can return plain text or XML, so how
 does the caller choose the one they want?

 I could have a format= parameter on the method call (Rackspace do that),
 or is it better to inspect the Accept header and obey it? Or something else?

 Greg K



Re: Web API response formatting

2014-01-19 Thread Jamie Surman
In WCF you use automaticFormatSelectionEnabled=true/false  to tell it to parse 
the header to work out what type of response to send back. I'm not sure whether 
it is the same in WebAPI. It seems a bit ugly to do via a querystring parameter.





 From: Greg Keogh g...@mira.net
To: ozDotNet ozdotnet@ozdotnet.com 
Sent: Monday, 20 January 2014 3:03 PM
Subject: Web API response formatting
 


Folks, what is the recommended way of letting the caller choose the format of 
the response? I have a method that can return plain text or XML, so how does 
the caller choose the one they want?

I could have a format= parameter on the method call (Rackspace do that), or is 
it better to inspect the Accept header and obey it? Or something else?

Greg K

Re: Web API response formatting

2014-01-19 Thread Greg Keogh
Chaps, after some doodling around I see I can get the Accept values
straight out of the Request in the controller's code. That does now seem to
be the logical way of choosing the response format.

More confusion though ... I tried to write a controller method that
returned either plain text or XML, but the samples I've found return
different types. One does this:

public HttpActionResult Sample1()
return Ok(hello);

public HttpResponseMessage Sample2()
return new HttpResponseMessage() { Content = new StringContent(hello) };






On 20 January 2014 13:12, Dave Walker rangitat...@gmail.com wrote:

 Accept header is the norm

 On 20 January 2014 15:03, Greg Keogh g...@mira.net wrote:

 Folks, what is the recommended way of letting the caller choose the
 format of the response? I have a method that can return plain text or XML,
 so how does the caller choose the one they want?

 I could have a format= parameter on the method call (Rackspace do that),
 or is it better to inspect the Accept header and obey it? Or something else?

 Greg K





Re: Web API response formatting

2014-01-19 Thread Greg Keogh
Please ignore previous message as I hit Send instead of Save (bloody Gmail
interface!). Here's the correct message:

Chaps, after some doodling around I see I can get the Accept values
straight out of the Request in the controller's code. That does now seem to
be the logical way of choosing the response format.

More confusion though ... I tried to write a controller method that
returned either plain text or XML, but the samples I've found return
different types. Here are the two samples:

public HttpActionResult Sample1()
return Ok(hello);

public HttpResponseMessage Sample2()
return new HttpResponseMessage() { Content = new StringContent(hello) };

The firsts returns Stringhello/String and the second returns the plain
text hello. But they're different return types and I can't figure out how
get one method to return Xml or text. Anyone know how. I'm still searching.

Greg K


Re: Web API response formatting

2014-01-19 Thread David Burstin
Greg, let the web API deal with the formatting. Your controller should
ideally just return an object which will be formatted according to the
request.

(apologies for brevity, I am playing mini golf with my son)

Try it in Fiddler and you can see how changing the request will change the
output. If you hard code the response type you are introducing unnecessary
coupling snd potential future headaches.

Sent from my flux capacitor. Please excuse brevity and any odd autocorrect
errors.
On 20/01/2014 1:54 PM, Greg Keogh g...@mira.net wrote:

 Please ignore previous message as I hit Send instead of Save (bloody Gmail
 interface!). Here's the correct message:

 Chaps, after some doodling around I see I can get the Accept values
 straight out of the Request in the controller's code. That does now seem to
 be the logical way of choosing the response format.

 More confusion though ... I tried to write a controller method that
 returned either plain text or XML, but the samples I've found return
 different types. Here are the two samples:

 public HttpActionResult Sample1()
 return Ok(hello);

 public HttpResponseMessage Sample2()
 return new HttpResponseMessage() { Content = new StringContent(hello) };

 The firsts returns Stringhello/String and the second returns the plain
 text hello. But they're different return types and I can't figure out how
 get one method to return Xml or text. Anyone know how. I'm still searching.

 Greg K



Re: Web API response formatting

2014-01-19 Thread David Burstin
From my limited reading on this I think you will struggle to remove the
xmlns, the rationale being that without a namespace the xml is not valid.
While technically true, it is also annoying.

Personally I have a strong preference for JSON these days and use it
whenever I can... simple, ubiquitous and hardly any rules to conform to.
YMMV.

Cheers
Dave

Sent from my flux capacitor. Please excuse brevity and any odd autocorrect
errors.
On 20/01/2014 3:03 PM, Greg Keogh g...@mira.net wrote:

 I can confirm that WebAPI does as you say and it looks for a formatter
 that matches the Accept header ... To make things easier and consistent for
 everyone I have abandoned the idea of returning plain text in some methods,
 I will always return an XML serialised class no matter how small the data
 might be. This is easier to document and the client will probably
 appreciate it. So the confusion about choosing text or xml will go away.
 I'll leave my text formatter there as a stub just in case someone wants csv
 formatting or similar later.

 I notice that if my controller method returns string then the xml
 formatter sends back Stringhello/String and Accept text/plain returns
 hello, which makes sense. If I try to get a class back as text it ignores
 me and I get XML anyway, which also makes sense.

 My task now is to remove the xmlns= clutter from the xml root.

 Part of my learners confusion is the large numbers of return types that
 are possible from controller methods, some not even in the same class
 hierarchy.

 Greg K



 On 20 January 2014 14:31, David Burstin david.burs...@gmail.com wrote:

 Greg, let the web API deal with the formatting. Your controller should
 ideally just return an object which will be formatted according to the
 request.

 (apologies for brevity, I am playing mini golf with my son)

 Try it in Fiddler and you can see how changing the request will change
 the output. If you hard code the response type you are introducing
 unnecessary coupling snd potential future headaches.

 Sent from my flux capacitor. Please excuse brevity and any odd
 autocorrect errors.
 On 20/01/2014 1:54 PM, Greg Keogh g...@mira.net wrote:

 Please ignore previous message as I hit Send instead of Save (bloody
 Gmail interface!). Here's the correct message:

 Chaps, after some doodling around I see I can get the Accept values
 straight out of the Request in the controller's code. That does now seem to
 be the logical way of choosing the response format.

 More confusion though ... I tried to write a controller method that
 returned either plain text or XML, but the samples I've found return
 different types. Here are the two samples:

 public HttpActionResult Sample1()
 return Ok(hello);

 public HttpResponseMessage Sample2()
 return new HttpResponseMessage() { Content = new StringContent(hello)
 };

 The firsts returns Stringhello/String and the second returns the
 plain text hello. But they're different return types and I can't figure
 out how get one method to return Xml or text. Anyone know how. I'm still
 searching.

 Greg K





Web API weird problems

2014-01-17 Thread Greg Keogh
Is anyone in here using Web API in anger? I'm experimenting with creating
an API that is simple and easy for non .NET clients to use. Controller
methods that return classes serialised as XML contain everything I expect
but...

*PROBLEM 1* : There are xmlsn= namespaces cluttering up the root node
that I can't get rid of. I tried a few tricks in web searches but it
changes nothing. Anyone know how to get rid of them and get plain XML?

My next hurdle is a POST to create a record. The Request below actually
works, but after hours of suffering I overcame two really weird problems to
make it work, otherwise you get the dreaded 500 error:

*PROBLEM-2* : The XML property elements have to be in alphabetical order
(no kidding!!). They are not in order inside the class.

*PROBLEM-3* : Related to No.1, I have to put the tedious namespaces in the
root element.

Greg K


POST http://raven/authapi/user/create HTTP/1.1
Content-Type: text/xml
Accept: application/xml
Host: raven

ApiUser xmlns:i=http://www.w3.org/2001/XMLSchema-instance; xmlns=
http://schemas.datacontract.org/2004/07/RCS.AuthService.RestApi;
  Namemax/Name
  PasswordT0pSecret/Password
  SpokenNameMax Headroom/SpokenName
/ApiUser


Re: Web API weird problems

2014-01-17 Thread Davy Jones
For problem 2: get codemaid plugin or resharper and reorder your
properties:

Or you could use an xslt to transform your serialization ordering your
properties as you go.

Davy.

Sent from my starfleet datapad.

On 17 janv. 2014, at 09:43, Greg Keogh g...@mira.net wrote:

Is anyone in here using Web API in anger? I'm experimenting with creating
an API that is simple and easy for non .NET clients to use. Controller
methods that return classes serialised as XML contain everything I expect
but...

*PROBLEM 1* : There are xmlsn= namespaces cluttering up the root node
that I can't get rid of. I tried a few tricks in web searches but it
changes nothing. Anyone know how to get rid of them and get plain XML?

My next hurdle is a POST to create a record. The Request below actually
works, but after hours of suffering I overcame two really weird problems to
make it work, otherwise you get the dreaded 500 error:

*PROBLEM-2* : The XML property elements have to be in alphabetical order
(no kidding!!). They are not in order inside the class.

*PROBLEM-3* : Related to No.1, I have to put the tedious namespaces in the
root element.

Greg K


POST http://raven/authapi/user/create HTTP/1.1
Content-Type: text/xml
Accept: application/xml
Host: raven

ApiUser xmlns:i=http://www.w3.org/2001/XMLSchema-instance; xmlns=
http://schemas.datacontract.org/2004/07/RCS.AuthService.RestApi;
  Namemax/Name
  PasswordT0pSecret/Password
  SpokenNameMax Headroom/SpokenName
/ApiUser


Re: Web API weird problems

2014-01-17 Thread David Burstin
Hi Greg,

Have you looked at either of the solutions in
http://stackoverflow.com/questions/12590801/remove-namespace-in-xml-from-asp-net-web-api

Cheers
Dave


On 17 January 2014 21:25, Davy Jones djones...@gmail.com wrote:

 For problem 2: get codemaid plugin or resharper and reorder your
 properties:

 Or you could use an xslt to transform your serialization ordering your
 properties as you go.

 Davy.

 Sent from my starfleet datapad.

 On 17 janv. 2014, at 09:43, Greg Keogh g...@mira.net wrote:

 Is anyone in here using Web API in anger? I'm experimenting with creating
 an API that is simple and easy for non .NET clients to use. Controller
 methods that return classes serialised as XML contain everything I expect
 but...

 *PROBLEM 1* : There are xmlsn= namespaces cluttering up the root node
 that I can't get rid of. I tried a few tricks in web searches but it
 changes nothing. Anyone know how to get rid of them and get plain XML?

 My next hurdle is a POST to create a record. The Request below actually
 works, but after hours of suffering I overcame two really weird problems to
 make it work, otherwise you get the dreaded 500 error:

 *PROBLEM-2* : The XML property elements have to be in alphabetical order
 (no kidding!!). They are not in order inside the class.

 *PROBLEM-3* : Related to No.1, I have to put the tedious namespaces in
 the root element.

 Greg K

 
 POST http://raven/authapi/user/create HTTP/1.1
 Content-Type: text/xml
 Accept: application/xml
 Host: raven

 ApiUser xmlns:i=http://www.w3.org/2001/XMLSchema-instance; xmlns=
 http://schemas.datacontract.org/2004/07/RCS.AuthService.RestApi;
   Namemax/Name
   PasswordT0pSecret/Password
   SpokenNameMax Headroom/SpokenName
 /ApiUser




Re: Web API weird problems

2014-01-17 Thread David Burstin
I tried the first of these but it didn't work for me. YMMV


On 17 January 2014 21:56, David Burstin david.burs...@gmail.com wrote:

 Hi Greg,

 Have you looked at either of the solutions in
 http://stackoverflow.com/questions/12590801/remove-namespace-in-xml-from-asp-net-web-api

 Cheers
 Dave


 On 17 January 2014 21:25, Davy Jones djones...@gmail.com wrote:

 For problem 2: get codemaid plugin or resharper and reorder your
 properties:

 Or you could use an xslt to transform your serialization ordering your
 properties as you go.

 Davy.

 Sent from my starfleet datapad.

 On 17 janv. 2014, at 09:43, Greg Keogh g...@mira.net wrote:

 Is anyone in here using Web API in anger? I'm experimenting with creating
 an API that is simple and easy for non .NET clients to use. Controller
 methods that return classes serialised as XML contain everything I expect
 but...

 *PROBLEM 1* : There are xmlsn= namespaces cluttering up the root node
 that I can't get rid of. I tried a few tricks in web searches but it
 changes nothing. Anyone know how to get rid of them and get plain XML?

 My next hurdle is a POST to create a record. The Request below actually
 works, but after hours of suffering I overcame two really weird problems to
 make it work, otherwise you get the dreaded 500 error:

 *PROBLEM-2* : The XML property elements have to be in alphabetical order
 (no kidding!!). They are not in order inside the class.

 *PROBLEM-3* : Related to No.1, I have to put the tedious namespaces in
 the root element.

 Greg K

 
 POST http://raven/authapi/user/create HTTP/1.1
 Content-Type: text/xml
 Accept: application/xml
 Host: raven

 ApiUser xmlns:i=http://www.w3.org/2001/XMLSchema-instance; xmlns=
 http://schemas.datacontract.org/2004/07/RCS.AuthService.RestApi;
   Namemax/Name
   PasswordT0pSecret/Password
   SpokenNameMax Headroom/SpokenName
 /ApiUser





Re: Web API weird problems

2014-01-17 Thread Michael Ridland
The first thing I did was remove the XML serializer. The json took over as
default and then I changed the json formatter(I think it's called) to the
camel case formatter.

Works nicely.


On Friday, January 17, 2014, David Burstin david.burs...@gmail.com wrote:

 I tried the first of these but it didn't work for me. YMMV


 On 17 January 2014 21:56, David Burstin 
 david.burs...@gmail.comjavascript:_e({}, 'cvml', 
 'david.burs...@gmail.com');
  wrote:

 Hi Greg,

 Have you looked at either of the solutions in
 http://stackoverflow.com/questions/12590801/remove-namespace-in-xml-from-asp-net-web-api

 Cheers
 Dave


 On 17 January 2014 21:25, Davy Jones djones...@gmail.comjavascript:_e({}, 
 'cvml', 'djones...@gmail.com');
  wrote:

 For problem 2: get codemaid plugin or resharper and reorder your
 properties:

 Or you could use an xslt to transform your serialization ordering your
 properties as you go.

 Davy.

 Sent from my starfleet datapad.

 On 17 janv. 2014, at 09:43, Greg Keogh g...@mira.netjavascript:_e({}, 
 'cvml', 'g...@mira.net');
 wrote:

 Is anyone in here using Web API in anger? I'm experimenting with
 creating an API that is simple and easy for non .NET clients to use.
 Controller methods that return classes serialised as XML contain everything
 I expect but...

 *PROBLEM 1* : There are xmlsn= namespaces cluttering up the root node
 that I can't get rid of. I tried a few tricks in web searches but it
 changes nothing. Anyone know how to get rid of them and get plain XML?

 My next hurdle is a POST to create a record. The Request below actually
 works, but after hours of suffering I overcame two really weird problems to
 make it work, otherwise you get the dreaded 500 error:

 *PROBLEM-2* : The XML property elements have to be in alphabetical
 order (no kidding!!). They are not in order inside the class.

 *PROBLEM-3* : Related to No.1, I have to put the tedious namespaces in
 the root element.

 Greg K

 
 POST http://raven/authapi/user/create HTTP/1.1
 Content-Type: text/xml
 Accept: application/xml
 Host: raven

 ApiUser xmlns:i=http://www.w3.org/2001/XMLSchema-instance; xmlns=
 http://schemas.datacontract.org/2004/07/RCS.AuthService.RestApi;
   Namemax/Name
   PasswordT0pSecret/Password
   SpokenNameMax Headroom/SpokenName
 /ApiUser






Re: Web API weird problems

2014-01-17 Thread Greg Keogh

 Have you looked at either of the solutions in
 http://stackoverflow.com/questions/12590801/remove-namespace-in-xml-from-asp-net-web-api


First part doesn't work, second part will require unpaid research time (as
usual) -- Greg


Re: Web API weird problems

2014-01-17 Thread Greg Keogh

 The first thing I did was remove the XML serializer.


Reverse that here ... I removed the Jason serialiser and only want the XML
serialiser. As far as I'm concerned, Json is a polluting blight on us all.
The C++ coding guys consuming my Web API will wet their pants if I tell
them there's another standard they have to deal with -- Greg


Web API Debugging

2014-01-14 Thread Greg Keogh
I accidentally solved the problem of how to debug and break a Web API app
in Visual Studio. I had to add a plain htm file to the project so I could
redirect there for help when a bad url was requested. That bit of
controller code looks like this, just in case it's of interest:

string authority = Request.RequestUri.GetLeftPart(UriPartial.Authority);
string url = string.Format({0}/{1}AuthApiHelp.htm, authority,
Request.RequestUri.Segments[1]);
return Redirect(url);
I set the htm file in Set as Start Page and when I hit F5 it fires up
with that page open, but I can do all the usual debugging. D'Oh, why didn't
I do that before?

Greg K


Re: Web API Debugging

2014-01-14 Thread David Burstin
Hi Greg,

Glad you got it fixed. I had tried multiple different approaches to try to
replicate your problem, but just couldn't find anything helpful.

Happy New Year mate.

Cheers
Dave

Sent from my flux capacitor. Please excuse brevity and any odd autocorrect
errors.
On 15/01/2014 1:33 PM, Greg Keogh g...@mira.net wrote:

 I accidentally solved the problem of how to debug and break a Web API app
 in Visual Studio. I had to add a plain htm file to the project so I could
 redirect there for help when a bad url was requested. That bit of
 controller code looks like this, just in case it's of interest:

 string authority = Request.RequestUri.GetLeftPart(UriPartial.Authority);
 string url = string.Format({0}/{1}AuthApiHelp.htm, authority,
 Request.RequestUri.Segments[1]);
 return Redirect(url);
 I set the htm file in Set as Start Page and when I hit F5 it fires up
 with that page open, but I can do all the usual debugging. D'Oh, why didn't
 I do that before?

 Greg K



Re: Debugging Web API

2013-12-29 Thread David Burstin
Hi Greg,
Sorry I haven't got back to you as promised. School holidays and kids have
gotten in the way. I will get back to you tonight.
Cheers
Dave
On 27/12/2013 3:40 PM, Greg Keogh g...@mira.net wrote:

 Sorry Greg, I am out all day. Will have a look tonight and get back to
 you. What sort of project are you using?

 I think I created an empty ASP.NET project then added the directory
 structure for Web API using one of the wizard steps. Then I right-clicked
 and added controllers, etc. Details are a bit vague now after a week. The
 project only contains files of type cs, config and asax.

 Greg



Re: Debugging Web API

2013-12-29 Thread Greg Keogh

 Sorry I haven't got back to you as promised. School holidays and kids have
 gotten in the way. I will get back to you tonight.

Don't panic, I return to REST experiments on Friday. For the last week, as
a hobby, I've been writing a T4 template that generates complete CRUD
classes over an Esent database.

Greg


Re: Debugging Web API

2013-12-26 Thread Greg Keogh

 In my VS solution my WebAPI project is set as the startup project. I run
 it with debugging and it just sits there running.


Dave, when I do that same I get:

HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.

Which is perfectly expected. Normally I would pick a file in Set as Start
Page but the project doesn't contain any suitable file. How do you get
your project to run?

Greg


Re: Debugging Web API

2013-12-26 Thread David Burstin
Sorry Greg, I am out all day. Will have a look tonight and get back to you.
What sort of project are you using?

Sent from my flux capacitor. Please excuse brevity and any odd autocorrect
errors.
On 27/12/2013 7:37 AM, Greg Keogh g...@mira.net wrote:

 In my VS solution my WebAPI project is set as the startup project. I run
 it with debugging and it just sits there running.


 Dave, when I do that same I get:

 HTTP Error 403.14 - Forbidden
 The Web server is configured to not list the contents of this directory.

 Which is perfectly expected. Normally I would pick a file in Set as Start
 Page but the project doesn't contain any suitable file. How do you get
 your project to run?

 Greg



Re: Debugging Web API

2013-12-26 Thread Greg Keogh

 Sorry Greg, I am out all day. Will have a look tonight and get back to
 you. What sort of project are you using?

I think I created an empty ASP.NET project then added the directory
structure for Web API using one of the wizard steps. Then I right-clicked
and added controllers, etc. Details are a bit vague now after a week. The
project only contains files of type cs, config and asax.

Greg


Re: Debugging Web API

2013-12-23 Thread Greg Keogh

 If my memory serves me correctly, I believe you can run the Web API
 solution and call the API from Fiddler. Any breakpoints you set will be
 hit. I am pretty sure that this has worked for me.

I'll try that, and I have to install a fresh Fiddler on my new system
anyway. I remember last time I had to jump through hoops to get Fiddler to
work with localhost, but maybe that's easier now -- Greg


RE: Debugging Web API

2013-12-23 Thread Steven Parish
Hi Greg,



The book mentioned the issue re fiddler with supporting localhost (with IE)
– but the latest version worked for me straight out of the box. It’s
interesting to watch what packets are going on your machine (more like
scary).



*Regards,*

*Steven Parish*



*Software Architect | BusinessCraft Pty Ltd | www.businesscraft.com
www.businesscraft.com*

Tel: (02) 4965  | Mob: 0417 688 599 | Fax: (02) 4965 5333 | Level 1,
270 Turton Road, New Lambton, NSW 2305
--



*Disclaimer*

The information contained in this and associated e-mails and any
attachments are confidential and were only intended solely for the use of
the addressee. If you have received this e-mail in error, please notify the
identified sender by return e-mail and then delete all copies of this and
associated emails and their attachments from your computer and or  your
computers system. Opinions, conclusions and other information in this
message that do not relate to the business of BusinessCraft Pty Ltd shall
be understood as neither given nor endorsed by it. It is your
responsibility to check the message and any attachments for any viruses
before use. BusinessCraft does not accept liability for any loss or damage
that may result, directly or indirectly from your receipt of this message
or any attachments contained within it.



*From:* ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
*On Behalf Of *Greg Keogh
*Sent:* Tuesday, 24 December 2013 5:56 AM
*To:* ozDotNet
*Subject:* Re: Debugging Web API



If my memory serves me correctly, I believe you can run the Web API
solution and call the API from Fiddler. Any breakpoints you set will be
hit. I am pretty sure that this has worked for me.

I'll try that, and I have to install a fresh Fiddler on my new system
anyway. I remember last time I had to jump through hoops to get Fiddler to
work with localhost, but maybe that's easier now -- Greg


Re: Debugging Web API

2013-12-23 Thread Greg Keogh

 The book mentioned the issue re fiddler with supporting localhost (with
 IE) – but the latest version worked for me straight out of the box. It’s
 interesting to watch what packets are going on your machine (more like
 scary).


Indeed .. in praise of Fiddler I must say I haven't used it for a year or
so and that time it was just to check the response headers of a service. I
took some time to look at all the tabs and features in the latest version
and I'm really impressed. It's great to be able to drag a session into the
Composer tab and play with it, and to see https traffic, and decode various
formats.

I was shocked by the amount of traffic from Gmail and Bing, the latter
caused by IE address bar suggestions which I have no use for and
deactivated.

I can see the requests and responses to my Web API, but I don't know how to
get VS2013 to break. I tried attaching to the Fiddler and IE process but it
doesn't work. Is there a trick to run the VS2013 project? There is no
Start Page like in a Web Forms, WCF or ASMX project.

Greg


Re: Debugging Web API

2013-12-23 Thread David Burstin
Hi Greg,

I am using VS2012. I just tested this and it works for me, but maybe there
is some voodoo setting that I have forgotten about.

In my VS solution my WebAPI project is set as the startup project. I run it
with debugging and it just sits there running. When I make a call to the
api via Fiddler, it breaks on the breakpoints that I have set. What is
happening for you? At which point does it not seem to work?

Cheers
Dave


On 24 December 2013 11:36, Greg Keogh g...@mira.net wrote:

 The book mentioned the issue re fiddler with supporting localhost (with
 IE) – but the latest version worked for me straight out of the box. It’s
 interesting to watch what packets are going on your machine (more like
 scary).


 Indeed .. in praise of Fiddler I must say I haven't used it for a year or
 so and that time it was just to check the response headers of a service. I
 took some time to look at all the tabs and features in the latest version
 and I'm really impressed. It's great to be able to drag a session into the
 Composer tab and play with it, and to see https traffic, and decode various
 formats.

 I was shocked by the amount of traffic from Gmail and Bing, the latter
 caused by IE address bar suggestions which I have no use for and
 deactivated.

 I can see the requests and responses to my Web API, but I don't know how
 to get VS2013 to break. I tried attaching to the Fiddler and IE process but
 it doesn't work. Is there a trick to run the VS2013 project? There is no
 Start Page like in a Web Forms, WCF or ASMX project.

 Greg



Debugging Web API

2013-12-22 Thread Greg Keogh
Folks, I'm writing my first Web API today because I found that a Borland
C++ client can not easily consume a SOAP service. You can run the Borland
wsdl utility on the service, but the .h file it generates doesn't look very
useful. I'm trying a Web API service as an alternative.

I'm running through this tutorial:
http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api

I can't find a way of debugging my project in the usual way of hitting F5.
There is no file to pick as the start page. There is no project property
I can find to set the url variables to test different types of calls.

I'm currently testing it by simply typing
http://mymachnie/myapi/api/foobars/123 into an IE address bar. If it works
I get a prompt to open some Json, if it throws I get a prompt with a weird
title that does nothing and I have no idea what went wrong.

Is there some debugging trick I'm missing?

Greg K


Re: Debugging Web API

2013-12-22 Thread Stephen Price
This *might* help you...

http://blogs.msdn.com/b/webdev/archive/2013/04/04/debugging-asp-net-web-api-with-route-debugger.aspx

Not sure. Most of the web api playing I've done (nothing yet for real, just
having a look) I also had a normal web app. So I'd run and debug the web
app, and because the web api side of things is in the same solution, any
debugging hits breakpoints etc. Nor sure how you'd go about debugging with
just web api. Perhaps you can attach debugger to you iis instance (or
whatever you are using)


On Mon, Dec 23, 2013 at 8:43 AM, Greg Keogh g...@mira.net wrote:

 Folks, I'm writing my first Web API today because I found that a Borland
 C++ client can not easily consume a SOAP service. You can run the Borland
 wsdl utility on the service, but the .h file it generates doesn't look very
 useful. I'm trying a Web API service as an alternative.

 I'm running through this tutorial:
 http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api

 I can't find a way of debugging my project in the usual way of hitting F5.
 There is no file to pick as the start page. There is no project property
 I can find to set the url variables to test different types of calls.

 I'm currently testing it by simply typing
 http://mymachnie/myapi/api/foobars/123 into an IE address bar. If it
 works I get a prompt to open some Json, if it throws I get a prompt with a
 weird title that does nothing and I have no idea what went wrong.

 Is there some debugging trick I'm missing?

 Greg K



Re: Debugging Web API

2013-12-22 Thread Greg Keogh


 http://blogs.msdn.com/b/webdev/archive/2013/04/04/debugging-asp-net-web-api-with-route-debugger.aspx


I tried following this and adding a Nuget package, but it bloated the tiny
project to a huge size and it wouldn't show the cshtml page when I set it
as the start page. It made such a mess I deleted my whole project and
folder and made a fresh one.

Pardon me, but I thought Web API development would be trivially easy, but I
keep stumbling upon gotchas and basic functionality hidden so it can only
be found in extensive Google searches. As soon as I want to do anything
that isn't in the kindergarten tutorials I'm up sh*t creek and spend most
of the day web searching as usual. No one so far has discussed the app
lifecycle and where things should live for how long, nor has anyone
explained how to scale-up with lots of controllers and rules.

I'm extremely disappointed with what I've found in my first exploration
this morning. The Web API seems to be another one of these bloated
infrastructures (like ASP.NET) which takes a simple idea and turns it into
a Rube Goldberg machine http://en.wikipedia.org/wiki/Rube_Goldberg_machine
.

Greg


Web API authentication

2013-12-22 Thread Greg Keogh
Folks, in SVC or ASMX services I usually have a method like
Authenticate(...) which takes credentials and returns some sort of token
which is used for subsequent calls from the same client. The token can be
passed out-of-band in a header so the client doesn't have to be bothered
by it.

I'd like to sue the same pattern in my Web API, but I'm not sure how to
implement the equivalent of passing the token in some sort of header. Has
anyone written this sort of plumbing or know if there some built-in
techniques I'm not aware of?

I know that the Rackspace REST API does exactly what I want, as you get a
Guid token which is valid for 24 hours. The tedious work of adding that
token to the outgoing http headers is handled deep down in some utility
classes in their SDK.

Greg K


Re: New Web API project

2013-02-03 Thread Heinrich Breedt
http://clear-measure.com/i-have-a-web-forms-custom-application-should-i-upgrade-to-asp-net-mvc-now-or-wait/


On Fri, Feb 1, 2013 at 2:25 PM, Heinrich Breedt heinrichbre...@gmail.comwrote:

 this might help:
 http://www.west-wind.com/weblog/posts/2012/Aug/07/Where-does-ASPNET-Web-API-Fit



 On Fri, Feb 1, 2013 at 12:35 PM, Katherine Moss katherine.m...@gordon.edu
  wrote:

  Yes, WebAPI is wrapped inside of MVC4.  And there’s another thing that
 just makes me mad; when people want to rewrite their application for the
 heck of it just so that they can be deployed under the latest fad.  The
 folks from Yet Another Forum are now saying that their project could be
 moved and rewritten as ASP.net MVC too, and for what?  To look cool?
 Apparently, and what’s wrong with a project that is written in Web Forms
 and doing fine?  I’m sorry, but I don’t get it.  And once that changes, if
 it does, other folks who use YAF will be screwed including those at
 Sueetie, who make a great product all based on Web Forms.  Though web forms
 and MVC can work together, though it’s not as simple as one would think.
 If you want MVC, then use Web Forms MVP.  And who said WCF is pointless
 middleware?  Isn’t it a good way to create web services?  And if not for
 WCF, what’s next?  Back to ASMX from 2006?  Come on!  Anyway, guys, I’m
 sorry for the rant, but I had to get it out somewhere, right?  

 ** **

 *From:* ozdotnet-boun...@ozdotnet.com [mailto:
 ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Greg Keogh
 *Sent:* Thursday, January 31, 2013 7:50 PM
 *To:* ozDotNet
 *Subject:* Re: New Web API project

 ** **

 Thanks, glad to know I'm not alone, that link looks sensible and will
 save a lot of suffering -- Greg 




 --
 Heinrich Breedt

 “Do not wait to strike till the iron is hot; but make it hot by striking.”
 - William B. Sprague




-- 
Heinrich Breedt

“Do not wait to strike till the iron is hot; but make it hot by striking.”
- William B. Sprague


Re: Web api

2013-02-01 Thread Stephen Price
Really? the only way to call Rest API's is with a third party add on?

I was kind of looking for the out of the box way. But will have a look at
RestSharp, always handy to know whats out there. They invent this stuff
faster than anyone can learn it all. :)


On Fri, Feb 1, 2013 at 2:53 PM, Mark Thompson matho...@internode.on.netwrote:

 You might like to try something like RestSharp ( http://restsharp.org/ )
 – it has some very nice helpers for adding request parameters and
 additional headers. I haven’t used it extensively, but for the times I have
 used it, it made the whole process pretty painless.

 ** **

 Regards,

 Mark.

 ** **

 *From:* ozdotnet-boun...@ozdotnet.com [mailto:
 ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Stephen Price
 *Sent:* Friday, 1 February 2013 4:38 PM
 *To:* ozDotNet
 *Subject:* Web api

 ** **

 Hey all,

 ** **

 While we are on the subject of MVC, I was looking about for an example or
 walkthrough of how you might call a Rest Web API from an MVC app. 

 ** **

 Not found much so far. I found a console C# app that uses the Asp.Net Web
 API Client libraries to call one. I've also found some examples of how to
 write the Web API's using MVC. 

 ** **

 So am scratching my head.. what httpX namespace is the right one to use?
 HttpClient? something else? 

 ** **

 cheers,

 Stephen



Re: Web api

2013-02-01 Thread Craig van Nieuwkerk
WebAPI are just normal urls like web pages. You can call using HttpClient

http://msdn.microsoft.com/en-us/library/system.net.http.httpclient.aspx


On Fri, Feb 1, 2013 at 7:15 PM, Stephen Price step...@perthprojects.comwrote:

 Really? the only way to call Rest API's is with a third party add on?

 I was kind of looking for the out of the box way. But will have a look at
 RestSharp, always handy to know whats out there. They invent this stuff
 faster than anyone can learn it all. :)


 On Fri, Feb 1, 2013 at 2:53 PM, Mark Thompson 
 matho...@internode.on.netwrote:

 You might like to try something like RestSharp ( http://restsharp.org/ )
 – it has some very nice helpers for adding request parameters and
 additional headers. I haven’t used it extensively, but for the times I have
 used it, it made the whole process pretty painless.

 ** **

 Regards,

 Mark.

 ** **

 *From:* ozdotnet-boun...@ozdotnet.com [mailto:
 ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Stephen Price
 *Sent:* Friday, 1 February 2013 4:38 PM
 *To:* ozDotNet
 *Subject:* Web api

 ** **

 Hey all,

 ** **

 While we are on the subject of MVC, I was looking about for an example or
 walkthrough of how you might call a Rest Web API from an MVC app. 

 ** **

 Not found much so far. I found a console C# app that uses the Asp.Net Web
 API Client libraries to call one. I've also found some examples of how to
 write the Web API's using MVC. 

 ** **

 So am scratching my head.. what httpX namespace is the right one to use?
 HttpClient? something else? 

 ** **

 cheers,

 Stephen





RE: Web api

2013-02-01 Thread Mark Thompson
Absolutely, there's nothing locking you into using a third-party tool to
access a REST endpoint. For me RestSharp had too many nice features in it
that made it an easy decision for me to justify using, but YMMV.

 

NuGet also makes it nice and easy to add this stuff to your projects, but
it's also easy to go overboard sometimes and bloat an otherwise simple
solution with a dozen different frameworks.

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of Craig van Nieuwkerk
Sent: Friday, 1 February 2013 7:10 PM
To: ozDotNet
Subject: Re: Web api

 

WebAPI are just normal urls like web pages. You can call using HttpClient

 

http://msdn.microsoft.com/en-us/library/system.net.http.httpclient.aspx

 

On Fri, Feb 1, 2013 at 7:15 PM, Stephen Price step...@perthprojects.com
wrote:

Really? the only way to call Rest API's is with a third party add on?

 

I was kind of looking for the out of the box way. But will have a look at
RestSharp, always handy to know whats out there. They invent this stuff
faster than anyone can learn it all. :)

 

On Fri, Feb 1, 2013 at 2:53 PM, Mark Thompson matho...@internode.on.net
wrote:

You might like to try something like RestSharp ( http://restsharp.org/ ) -
it has some very nice helpers for adding request parameters and additional
headers. I haven't used it extensively, but for the times I have used it, it
made the whole process pretty painless.

 

Regards,

Mark.

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of Stephen Price
Sent: Friday, 1 February 2013 4:38 PM
To: ozDotNet
Subject: Web api

 

Hey all,

 

While we are on the subject of MVC, I was looking about for an example or
walkthrough of how you might call a Rest Web API from an MVC app. 

 

Not found much so far. I found a console C# app that uses the Asp.Net Web
API Client libraries to call one. I've also found some examples of how to
write the Web API's using MVC. 

 

So am scratching my head.. what httpX namespace is the right one to use?
HttpClient? something else? 

 

cheers,

Stephen

 

 



Re: Web api

2013-02-01 Thread Heinrich Breedt
.net client: httpclient
Webpage: ajax get/post
On 1 Feb 2013 18:16, Stephen Price step...@perthprojects.com wrote:

 Really? the only way to call Rest API's is with a third party add on?

 I was kind of looking for the out of the box way. But will have a look at
 RestSharp, always handy to know whats out there. They invent this stuff
 faster than anyone can learn it all. :)


 On Fri, Feb 1, 2013 at 2:53 PM, Mark Thompson 
 matho...@internode.on.netwrote:

 You might like to try something like RestSharp ( http://restsharp.org/ )
 – it has some very nice helpers for adding request parameters and
 additional headers. I haven’t used it extensively, but for the times I have
 used it, it made the whole process pretty painless.

 ** **

 Regards,

 Mark.

 ** **

 *From:* ozdotnet-boun...@ozdotnet.com [mailto:
 ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Stephen Price
 *Sent:* Friday, 1 February 2013 4:38 PM
 *To:* ozDotNet
 *Subject:* Web api

 ** **

 Hey all,

 ** **

 While we are on the subject of MVC, I was looking about for an example or
 walkthrough of how you might call a Rest Web API from an MVC app. 

 ** **

 Not found much so far. I found a console C# app that uses the Asp.Net Web
 API Client libraries to call one. I've also found some examples of how to
 write the Web API's using MVC. 

 ** **

 So am scratching my head.. what httpX namespace is the right one to use?
 HttpClient? something else? 

 ** **

 cheers,

 Stephen





RE: New Web API project

2013-02-01 Thread Paul Glavich
I believe it is an artefact of wanting to enable SPA (Single Page
applications). That is, a web app, using mostly a single page, comprised of
a lot of javascript calls to a WebApi backend.

 

It will be rationalised soon enough I believe.

 

-  Glav

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of Greg Keogh
Sent: Friday, 1 February 2013 9:39 AM
To: ozDotNet
Subject: New Web API project

 

I thought I'd generate a fresh Web API project from the template to see what
it looks like, and I eventually find it under ASP MVC 4. I do so and get 143
files in 20 folders. There are scripts, images, cshtml files, style sheets
and lord knows what. What is all this sh*t just to make a http service?

 

I expected to get a concise little project with some skeleton files but I
get this gigantic schmozzle. Are you telling me that a Web API project is
wrapped-up inside the circus of the ASP MVC framework?

 

Am I expected to delete all the irrelevent files and strip it back to a
simple service without a UI, or is there a simpler way of creating a Web API
project from scratch?

 

Greg

 

P.S. Silverlight still works best with WCF. You could make http requests
from Silverlight, but it's all typeless. I'm not sure if there is some trick
to make them work together more pleasantly.



RE: SPAM-LOW Re: Web api

2013-02-01 Thread Paul Glavich
HttpClient as already suggested but, the framework does suffer from a myriad
of choices (mostly due to historical choices). HttpWebRequest can do it too,
any number of proxies as well. Or you can go lower level but I would suggest
getting familiar with HttpClient. That way of working is the way things will
get done in the future (imho).

 

-  Glav

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of Heinrich Breedt
Sent: Friday, 1 February 2013 8:08 PM
To: ozDotNet
Subject: SPAM-LOW Re: Web api

 

.net client: httpclient
Webpage: ajax get/post 

On 1 Feb 2013 18:16, Stephen Price step...@perthprojects.com
mailto:step...@perthprojects.com  wrote:

Really? the only way to call Rest API's is with a third party add on?

 

I was kind of looking for the out of the box way. But will have a look at
RestSharp, always handy to know whats out there. They invent this stuff
faster than anyone can learn it all. :)

 

On Fri, Feb 1, 2013 at 2:53 PM, Mark Thompson matho...@internode.on.net
mailto:matho...@internode.on.net  wrote:

You might like to try something like RestSharp ( http://restsharp.org/ ) -
it has some very nice helpers for adding request parameters and additional
headers. I haven't used it extensively, but for the times I have used it, it
made the whole process pretty painless.

 

Regards,

Mark.

 

From: ozdotnet-boun...@ozdotnet.com mailto:ozdotnet-boun...@ozdotnet.com
[mailto:ozdotnet-boun...@ozdotnet.com mailto:ozdotnet-boun...@ozdotnet.com
] On Behalf Of Stephen Price
Sent: Friday, 1 February 2013 4:38 PM
To: ozDotNet
Subject: Web api

 

Hey all,

 

While we are on the subject of MVC, I was looking about for an example or
walkthrough of how you might call a Rest Web API from an MVC app. 

 

Not found much so far. I found a console C# app that uses the Asp.Net Web
API Client libraries to call one. I've also found some examples of how to
write the Web API's using MVC. 

 

So am scratching my head.. what httpX namespace is the right one to use?
HttpClient? something else? 

 

cheers,

Stephen

 



RE: New Web API project

2013-01-31 Thread Katherine Moss
Thank you for the clarification, guys.  My thing, since I'm planning to become 
an open source developer, still, I think that even if I am developing for open 
source, if I am happy, then I'll keep one project in one technology if it is 
working for me, and then I'll offer a port of it in the other platform or 
something like that so that people can choose which project they feel more 
comfortable using.  Or I'll just choose whichever one works.  I feel that there 
is no reason to change a project that is working just for the heck of it, but 
that's me.  But, the good news is that it doesn't look like YAF will be moving 
since there is now a rival forum written in ASP.net MVC right now.  So it would 
be stupid for them to do that.  And considering they are commercial as well.  
And speaking of ASP.net MVC though, I have noticed that not many people use the 
standard ASPX view, do they?  I mean, what's so special about razor if razor is 
sort of backtracking to the ASP days?  I mean, C# within HTML tags?  Come on, 
people.  Go back to VBScript if you're going to do that.

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On 
Behalf Of Heinrich B
Sent: Thursday, January 31, 2013 11:25 PM
To: ozDotNet
Subject: Re: New Web API project

this might help: 
http://www.west-wind.com/weblog/posts/2012/Aug/07/Where-does-ASPNET-Web-API-Fit

On Fri, Feb 1, 2013 at 12:35 PM, Katherine Moss 
katherine.m...@gordon.edumailto:katherine.m...@gordon.edu wrote:
Yes, WebAPI is wrapped inside of MVC4.  And there's another thing that just 
makes me mad; when people want to rewrite their application for the heck of it 
just so that they can be deployed under the latest fad.  The folks from Yet 
Another Forum are now saying that their project could be moved and rewritten as 
ASP.net MVC too, and for what?  To look cool?  Apparently, and what's wrong 
with a project that is written in Web Forms and doing fine?  I'm sorry, but I 
don't get it.  And once that changes, if it does, other folks who use YAF will 
be screwed including those at Sueetie, who make a great product all based on 
Web Forms.  Though web forms and MVC can work together, though it's not as 
simple as one would think.  If you want MVC, then use Web Forms MVP.  And who 
said WCF is pointless middleware?  Isn't it a good way to create web services?  
And if not for WCF, what's next?  Back to ASMX from 2006?  Come on!  Anyway, 
guys, I'm sorry for the rant, but I had to get it out somewhere, right?

From: ozdotnet-boun...@ozdotnet.commailto:ozdotnet-boun...@ozdotnet.com 
[mailto:ozdotnet-boun...@ozdotnet.commailto:ozdotnet-boun...@ozdotnet.com] On 
Behalf Of Greg Keogh
Sent: Thursday, January 31, 2013 7:50 PM
To: ozDotNet
Subject: Re: New Web API project

Thanks, glad to know I'm not alone, that link looks sensible and will save a 
lot of suffering -- Greg



--
Heinrich Breedt

Do not wait to strike till the iron is hot; but make it hot by striking. - 
William B. Sprague


Re: New Web API project

2013-01-31 Thread Heinrich Breedt
I think you have the wrong idea about MVC.
Razor Views specifically: It all gets executed server side. You certainly
dont have to use it. These days I do a lot of knockout pages with hardly
any razor in them, sometimes not at all.
It can look a lot like old asp i guess, and with all things it can lead to
spaghetti code. But I much prefer to be close to the metal with my html.
Much better than serverside controls and writing html inside page response.
And if i never have to deal with the page lifecycle it will be too soon.


On Fri, Feb 1, 2013 at 3:19 PM, Katherine Moss katherine.m...@gordon.eduwrote:

  Thank you for the clarification, guys.  My thing, since I’m planning to
 become an open source developer, still, I think that even if I am
 developing for open source, if I am happy, then I’ll keep one project in
 one technology if it is working for me, and then I’ll offer a port of it in
 the other platform or something like that so that people can choose which
 project they feel more comfortable using.  Or I’ll just choose whichever
 one works.  I feel that there is no reason to change a project that is
 working just for the heck of it, but that’s me.  But, the good news is that
 it doesn’t look like YAF will be moving since there is now a rival forum
 written in ASP.net MVC right now.  So it would be stupid for them to do
 that.  And considering they are commercial as well.  And speaking of
 ASP.net MVC though, I have noticed that not many people use the standard
 ASPX view, do they?  I mean, what’s so special about razor if razor is sort
 of backtracking to the ASP days?  I mean, C# within HTML tags?  Come on,
 people.  Go back to VBScript if you’re going to do that.  

 ** **

 *From:* ozdotnet-boun...@ozdotnet.com [mailto:
 ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Heinrich B
 *Sent:* Thursday, January 31, 2013 11:25 PM

 *To:* ozDotNet
 *Subject:* Re: New Web API project

 ** **

 this might help:
 http://www.west-wind.com/weblog/posts/2012/Aug/07/Where-does-ASPNET-Web-API-Fit
  

 ** **

 On Fri, Feb 1, 2013 at 12:35 PM, Katherine Moss katherine.m...@gordon.edu
 wrote:

 Yes, WebAPI is wrapped inside of MVC4.  And there’s another thing that
 just makes me mad; when people want to rewrite their application for the
 heck of it just so that they can be deployed under the latest fad.  The
 folks from Yet Another Forum are now saying that their project could be
 moved and rewritten as ASP.net MVC too, and for what?  To look cool?
 Apparently, and what’s wrong with a project that is written in Web Forms
 and doing fine?  I’m sorry, but I don’t get it.  And once that changes, if
 it does, other folks who use YAF will be screwed including those at
 Sueetie, who make a great product all based on Web Forms.  Though web forms
 and MVC can work together, though it’s not as simple as one would think.
 If you want MVC, then use Web Forms MVP.  And who said WCF is pointless
 middleware?  Isn’t it a good way to create web services?  And if not for
 WCF, what’s next?  Back to ASMX from 2006?  Come on!  Anyway, guys, I’m
 sorry for the rant, but I had to get it out somewhere, right?  

  

 *From:* ozdotnet-boun...@ozdotnet.com [mailto:
 ozdotnet-boun...@ozdotnet.com] *On Behalf Of *Greg Keogh
 *Sent:* Thursday, January 31, 2013 7:50 PM
 *To:* ozDotNet
 *Subject:* Re: New Web API project

  

 Thanks, glad to know I'm not alone, that link looks sensible and will save
 a lot of suffering -- Greg 



 

 ** **

 --
 Heinrich Breedt

 “Do not wait to strike till the iron is hot; but make it hot by striking.”
 - William B. Sprague 




-- 
Heinrich Breedt

“Do not wait to strike till the iron is hot; but make it hot by striking.”
- William B. Sprague


Web api

2013-01-31 Thread Stephen Price
Hey all,

While we are on the subject of MVC, I was looking about for an example or
walkthrough of how you might call a Rest Web API from an MVC app.

Not found much so far. I found a console C# app that uses the Asp.Net Web
API Client libraries to call one. I've also found some examples of how to
write the Web API's using MVC.

So am scratching my head.. what httpX namespace is the right one to use?
HttpClient? something else?

cheers,
Stephen


RE: Web api

2013-01-31 Thread Mark Thompson
You might like to try something like RestSharp ( http://restsharp.org/ ) -
it has some very nice helpers for adding request parameters and additional
headers. I haven't used it extensively, but for the times I have used it, it
made the whole process pretty painless.

 

Regards,

Mark.

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of Stephen Price
Sent: Friday, 1 February 2013 4:38 PM
To: ozDotNet
Subject: Web api

 

Hey all,

 

While we are on the subject of MVC, I was looking about for an example or
walkthrough of how you might call a Rest Web API from an MVC app. 

 

Not found much so far. I found a console C# app that uses the Asp.Net Web
API Client libraries to call one. I've also found some examples of how to
write the Web API's using MVC. 

 

So am scratching my head.. what httpX namespace is the right one to use?
HttpClient? something else? 

 

cheers,

Stephen



Re: New Web API project

2013-01-31 Thread Nathan Schultz
There are advantages of using MVC for open-source software:
 - You don't have to deal with the web-forms 'generated' naming
conventions of rendered HTML which can make it hard to integrate with
JavaScript frameworks
 - You have greater control over the HTML, which means it's easier to
implement open-source HTML frameworks such as HTML5 Boiler Plate, or
Foundation 3.
 - You're not reliant on ASP's rendering of server controls, so it's
easier to write standards compliant HTML
 - There is better separation of concerns between the view code and
logic, which leads to better transparency - always helpful when
working in disparate teams like in the Open Source community.
 - Testability: Unlike Web-Forms that are difficult to automatically
test; MVC makes testing frameworks first-class citizens, and the boon
from this cannot be understated:
. You can regression test at the click of a button - almost
essential when others are poking around with your code.
. It can also be used as a 'contract' when working with other
developers - you know what is implemented and working, and what is
not.
. I find Testable code is also better designed code: you think
about separation of concerns and dependencies much more
. There's nothing like getting to 'code freeze' and finding you
have to do a re-design due to uncovering a fundamental flaw. With a
test suite to back you up, re-factoring your design is far less scary.



On 1 February 2013 13:47, Heinrich Breedt heinrichbre...@gmail.com wrote:
 I think you have the wrong idea about MVC.
 Razor Views specifically: It all gets executed server side. You certainly
 dont have to use it. These days I do a lot of knockout pages with hardly any
 razor in them, sometimes not at all.
 It can look a lot like old asp i guess, and with all things it can lead to
 spaghetti code. But I much prefer to be close to the metal with my html.
 Much better than serverside controls and writing html inside page response.
 And if i never have to deal with the page lifecycle it will be too soon.


 On Fri, Feb 1, 2013 at 3:19 PM, Katherine Moss katherine.m...@gordon.edu
 wrote:

 Thank you for the clarification, guys.  My thing, since I’m planning to
 become an open source developer, still, I think that even if I am developing
 for open source, if I am happy, then I’ll keep one project in one technology
 if it is working for me, and then I’ll offer a port of it in the other
 platform or something like that so that people can choose which project they
 feel more comfortable using.  Or I’ll just choose whichever one works.  I
 feel that there is no reason to change a project that is working just for
 the heck of it, but that’s me.  But, the good news is that it doesn’t look
 like YAF will be moving since there is now a rival forum written in ASP.net
 MVC right now.  So it would be stupid for them to do that.  And considering
 they are commercial as well.  And speaking of ASP.net MVC though, I have
 noticed that not many people use the standard ASPX view, do they?  I mean,
 what’s so special about razor if razor is sort of backtracking to the ASP
 days?  I mean, C# within HTML tags?  Come on, people.  Go back to VBScript
 if you’re going to do that.



 From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
 On Behalf Of Heinrich B
 Sent: Thursday, January 31, 2013 11:25 PM


 To: ozDotNet
 Subject: Re: New Web API project



 this might help:
 http://www.west-wind.com/weblog/posts/2012/Aug/07/Where-does-ASPNET-Web-API-Fit



 On Fri, Feb 1, 2013 at 12:35 PM, Katherine Moss
 katherine.m...@gordon.edu wrote:

 Yes, WebAPI is wrapped inside of MVC4.  And there’s another thing that
 just makes me mad; when people want to rewrite their application for the
 heck of it just so that they can be deployed under the latest fad.  The
 folks from Yet Another Forum are now saying that their project could be
 moved and rewritten as ASP.net MVC too, and for what?  To look cool?
 Apparently, and what’s wrong with a project that is written in Web Forms and
 doing fine?  I’m sorry, but I don’t get it.  And once that changes, if it
 does, other folks who use YAF will be screwed including those at Sueetie,
 who make a great product all based on Web Forms.  Though web forms and MVC
 can work together, though it’s not as simple as one would think.  If you
 want MVC, then use Web Forms MVP.  And who said WCF is pointless middleware?
 Isn’t it a good way to create web services?  And if not for WCF, what’s
 next?  Back to ASMX from 2006?  Come on!  Anyway, guys, I’m sorry for the
 rant, but I had to get it out somewhere, right?



 From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
 On Behalf Of Greg Keogh
 Sent: Thursday, January 31, 2013 7:50 PM
 To: ozDotNet
 Subject: Re: New Web API project



 Thanks, glad to know I'm not alone, that link looks sensible and will save
 a lot of suffering -- Greg





 --
 Heinrich Breedt

 “Do not wait to strike till the iron is hot