MVC Routes Rest Standards URL Parameters

Jun 21, 2011

I have the following controller actions:
<HttpGet()>
Function News() As ActionResult
End Function
<HttpGet()>
Function News(ByVal id As Integer) As ActionResult
End Function

I want it to be smart, and go to the first if I have no ID in the url, and the second if there is. I got the following error:
The current request for action 'News' on controller type 'MarketsController' is ambiguous >between the following action methods:
System.Web.Mvc.ActionResult News() on type TradeChaseMVC.MarketsController
System.Web.Mvc.ActionResult News(Int32) on type TradeChaseMVC.MarketsController

So, I thought if i explicitly created routes without the id parameter optional, like this:
routes.MapRoute( _
"Default2", _
"{controller}/{action}/{id}",
New With {.controller = "Home", .action = "Index"},
New With {.action = "^[a-zA-Z_]+$", .id = "d{1,8}|"}
[Code] .....

It would work, but it doesn't same error. Now I know the simple solution is to call my methods different things, but i don't want to do this. I was also thinking of creating an attribute to prefix the ID method, to check for ID being there, and if it isn't dont allow that method, but I can't get this to work either.

View 2 Replies


ADVERTISEMENT

C# - Coding Standards For .NET?

Oct 25, 2010

Possible Duplicate: C# Coding standard / Best practices

What VB.NET or C# coding standards are you using for your .NET applications?I was looking at hungarian notation and I don't think it is a good idea for a .NET application.

View 7 Replies

Test ASP.NET MVC Routes Using MVC Contrib?

Jul 21, 2009

I'm trying to set up Route mapping tests using MVC Contrib as described in Test ASP.NET MVC routes using MVC Contrib .The tests compile and execute, but they always fail with the message "The URL did not match any route."I set up another test to try to get an idea of what the problem is:

Public Sub TestIndexRoute()
Dim routes = New RouteCollection
myMvcApp.MvcApplication.RegisterRoutes(routes)[code].....

That test fails on Assert.NotNull(routeData, "routeData is Nothing."), so I know that there must be some problem with the MVCContrib code that is trying to access my app's RouteCollection.From the blog post:It also assumes you set your routes in the ASP.NET MVC RouteCollection object.How do I confirm that I'm doing that? I'm using routes.MapRoute within MvcApplication.RegisterRoutes method in the Global.asax code behind. Is there something else to do to set this up properly?

View 1 Replies

Operators - <> And Not - Write Standards Documentation ?

Mar 16, 2009

I'm having the exciting task of finding out about VB.NET's <> and Not operators. Not - I'm assuming by my small use of it - is the functional equivalent of ! in languages such as C# and <> being equivalent of !=.

In VB.NET a common problem is doing Boolean expressions against objects that don't have a reference, it appears. So if we do If Request.QueryString("MyQueryString") <> Nothing Then This will actually fail if the query string doesn't exist. Why, I don't know. The way that it's done by older coders is as follows: If Not Request.QueryString("MyQueryString") Is Nothing Then

And this tends to work. To me they're functionally equivalent though operators tend to do different comparisons dependent on certain factors such as operator precedence, why it doesn't work in this case however, I do not know, and neither have I found any relevant material. I ask this as I'm having to write standards documentation and we're determining the use of either the Not or <>.

View 7 Replies

Response Format Specification In ASP.NET MVC 3 Routes?

Apr 15, 2011

I'm creating an API for a website. I'm using ASP.Net MVC 3 and I'm trying to create routes that support an optional .format parameter. So the client app could request /user/post.json, /user/posts.xml or just /users/posts I was able to make the .json or .xml ending url's work using the following route:

routes.MapRoute( _
"no_params", _

[code]....

But I couldn't make the url without the .format parameter (/user/posts) work alongside.

View 2 Replies

VS 2008 Naming Standards For Constants?

Feb 24, 2010

Are there any naming standards for constants that are different than variables? ex: Const for the prefix of the name.

View 3 Replies

VS 2010 Form Naming Standards?

Jun 6, 2011

have a form that is used to enter employee information and I also have a class object that I use to validate data and pass employee information around. What are the proper names for the form and the class?

View 9 Replies

ASP NET MVC Area Routing/multiple Routes Issue In VB

Sep 14, 2011

"Multiple types were found that match the controller named 'reviews'. This can happen if the route that services this request ('{controller}/{action}/{id}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter."

I've recently added a new "Admin" area to my app and within that I have a "ReviewController". There is also a "ReviewController" within the main app folder:

ah - as a new user I can't post an image, but basically I have a "ReviewController" in "Controllers" and in "Areas/Admin/Contollers".

I have 2 routes set up so far:

Default route in Global.asax.vb
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")

[Code].....

View 1 Replies

ASP.NET MVC2 Lowercase Routes In Visual Basic

Jul 7, 2010

I have found 4 or 5 examples of "lowercase routes" in C# however when I use the telerik code converter, I get a bunch of errors. Namely something to do with "extension methods can be defined only in modules." how to map routes to lowercase in VB?

[Code]...

View 1 Replies

Standard Or Standards For Communications, File Formats And So Forth?

Sep 6, 2010

What international organisations exist for agreeing a standard or standards for communications, file formats and so forth?I know for instance you can apply to a company like.>>URL}..to get a barcode.

For more see.>> http://www.google.co.uk/#hl=en&source=hp&q=how+do+you+get+a+barcode&fp=9b029eaa092cce63

View 12 Replies

Asp.net - Concept Needed For Building Consistent Urls (routes)?

Nov 24, 2010

My project has the need to build consistent urls similar to the ones here on stackoverflow. I know how I "can" do it by running the string through multiple filters, but I'm wondering if I can do it all with a single method.Basically I want to remove all special characters, and replace them with dashes BUT if there are multiple dashes in a row, I need them to be a single dash. How can I implement this as clean as possible?

[Code]...

View 2 Replies

C# - Search For Names In The Database That Matches Whole Parameters Or Any Part Of Parameters

May 13, 2011

I'm writing a query to select all records that has any part of parameter. I have one table called Employees. Some people have name like this: John David Clark If the parameter is

[Code]....

I should be able to get result back as long as there's a match in the parameters. If I use Function Contains (q.FirstName & " " & q.LastName).Contains(employeeName), I will not get any result back if employeeName is "John Clark" Function Contains looks only for next words from left to right. It doesn't match a single word at a time. So that's why I used this in the Linq to SQL:

[Code]....

View 2 Replies

Error [07002] The # Binded Parameters < The # Of Parameters Makers

Aug 30, 2010

I am getting error [07002] the # binded parameters < the # of parameters makers, i checked both parameters were perfect even though i am getting this error here is my code

[Code]...

View 1 Replies

How To Do This XML REST Reqest In .net

Aug 13, 2011

How do I post this HTTP REST request using HttpWebRequest and System.Xml.XmlDocument in vb.net

<tns:request command="hello" xmlns:tns="http://www.xxyyzz.com/xx/yy/zz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />

The server responds with

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><response xmlns="http://www.xxyyzz.com/xx/yy/zz"><operation location="/mm/10d9c79e-5876-4fd0-9093-ff7bdee5ebd4/uploadInfo" command="uploadInfo"/></response>

how do i capture this response?

View 1 Replies

Attachments Using REST WebService

May 26, 2011

I am currently developing an application using VB.NET in which I am using the REST WebServices. I have been able to do the basics with REST, however, I have not been able to add an attachment (more specifically upload a file, using REST which gets attached). I have done extensive research online, but so far I have not been able to find any working examples in VB.NET. To actually upload the data I use System.Net.WebClient. The following VB.NET code does the important work:[code]As you can see, the postString is converted to bytes and then uploaded to the server. However, I do not know where or how I should be posting the raw attachment itself. The documentation for the service we are specifically using states to use a variable "attachment_ 1," which I added to the postString variable, but I am not sure what the next step should be. Should the file be converted into bytes and appended to the postBytes variable?

View 1 Replies

End The Execution Of The Rest Of The Code?

Sep 2, 2009

i am getting an input from the user and i m checking in try catch statement. what i want to do is when the exception is caught i want to stop executing the rest of the code. my code is as below

Public Class AddForm
Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click
Dim inc As Integer[code]......

View 4 Replies

Finishing The Rest Of The Line?

Jun 25, 2010

When I start typing a variable (or whatever), VB pops up a little box with all possible variables starting with the letters I already typed. It's really smart!

However this option has somehow been disabled. How do I enable it again?

View 7 Replies

Parse REST XML File?

Jan 2, 2011

I am working on a .NET 3.5 Windows Forms application that will interact with a REST Web Service which outputs an XML file such as the following:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Response Status="OK">
<Item Name="NumberZones">2</Item>

[code].....

View 2 Replies

Send Over Data To A REST API?

Dec 18, 2009

I need to send over data to a REST API.I have a dataset with a datatable with the nececessary data. The data has to be in a specific format. I have a .xsd file with the format needed and a .xml file with an example.

View 26 Replies

Setting RequestHeaders For Get REST API In VB?

May 11, 2012

I have located some sample source code in visual basic to call a REST API. However, I need to modify the code by adding two request headers.

' Create the web request
request = DirectCast(WebRequest.Create(sURI), HttpWebRequest)
'Update request headers with request pairs Header1/"header1 value" and header2/"header2 value"
??? HttpWebRequest.headers.Add ????

[code]....

View 2 Replies

Stopping The Rest Of The Code?

Jun 23, 2009

I have this code within a button: If TextBox1.TextLength = 3 Then MsgBox("Please enter 3 numbers followed by a letter. For Example 001A")TextBox1.Text = "" Me.Refresh() End If Although if the user enters 3 numbers only, I want the rest of the code in the button to be ignored so that it doesn't proceed.

[Code]...

View 3 Replies

Tab Not Anchored With The Rest Of The Form?

Jan 30, 2010

For this program im using http method post to recieve messages from the server, when its waiting for a new message to be sent it locks the program up. No biggie, ill just thread the sub... Bad idea... I also have functions "send", "Connect", "disconnect". All on threads... i looked at task manager it started getting up to 100+ threads. I dont know much about threads but that just seems way to much. they will die off and the count will return to 20 but id like to find a different way of keeping the program from locking up but not having 100+ threads.. Little off topic: i used a user control. The only problem now is on the tab, its not anchored with the rest of the form... how do i accomplish this?

View 4 Replies

Wcf - Building A .NET REST Service?

Nov 5, 2010

I cannot figure out how to build a VB.NET REST web service. I can't find any tutorials on the internet and the Microsoft templates only come in C#.

View 2 Replies

Asp.net - Add A Rest Service To A Web Application Project?

Feb 16, 2012

I've just created my first web application project.Now I want to add a RESTFul service.It can be pretty simple, all I need is to pass 1 string (userid) and 1 integer (objecttype) and return a json result.

View 1 Replies

C# - How A Month Is Calculated In The Rest Of The World

Jan 11, 2012

I'm just curious that how a month is calculated in the rest of the world because Differences in Months between two dates are calculated differently. In our Insurance Company, we calculate a month as below:

[Code]...

View 1 Replies

C# :: Does .net Stop Checking The Rest Of An IF Statement If Use An And/or ( || / && )

Jun 24, 2011

say you have something like:

int num = 0
then you do
if(num > 5 || num < 4)

[code]....

View 3 Replies

Call Authenticated Rest Service?

Jan 18, 2012

private String[] createid(String id,HttpServletRequest req) throws Exception {

try {

final Client client = Client.create(); [code]....

View 1 Replies

Get Data From A Button Into The Rest Of The Program?

Feb 17, 2011

I'm trying to write a program which allows a user to determine how many 'I's will go into a text box. (i.e if they select 10 then the text box will look like I I I I I I I I I I ). I'm writing a program where if I click on one of three buttons then a number of 'I's will disappear out of the text box. Button one will subtract one 'I', button two will subtract two 'I's, and button three will subract 3 'I's. I don't know how to get the information from the button into the program to subtract the correct number of 'I's. If I press button one, and I have:

Dim OneI as Integer = 1

How do I get the 1 in the OneI variable into a calculation outside of the btn sub, like into a function or a different sub?

View 3 Replies

Hide Variable From The Rest Of The Class?

May 22, 2009

Public Class frmMain
Private p_dlgAdd As frmAdd = Nothing
Public ReadOnly Property _dlgAdd As frmAdd

[code].....

View 4 Replies

How To Do First Select Case Can Figure Rest Out

Feb 18, 2010

I found this code on here while doing a search and would like to be able to use it but it was written in C and I dont know much about that (don't know that much about VB.NET either but trying to learn)[code]What I do have is a text box where a user enteres a desired number of US dollars to convert to three types of currency.I know how to convert the string entered to an integer so the calculation can take place. What I don't know how to do is modify the above code so that the results will show up in the correct text boxes after each calculation (yes I know I have to convert the integer back to text).If someone could show me how to do the first Select Case I can figure the rest out.

View 12 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved