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


ADVERTISEMENT

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

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

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

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

Argument Not Specified For Parameter 'test' Of 'Public Shared Function TestThis(test As String)'?

Sep 25, 2010

I don't understand the error, Argument not specified for parameter 'test' of 'Public Shared Function TestThis(test As String)'.

Partial Public Class Form1
Shared Sub ReceiveCallback(ByVal ar As IAsyncResult)
Form1.Invoke(TestThis, New Object(){"test"}) 'error

[code].....

View 6 Replies

Reference To Test.dll But An Error Messege Was Appear A Reference To Test.dll File Could Not Be Added?

May 25, 2009

[code]...

and from VB6 project I reference to Test.dll but an error messege was appear A reference to Test.dll file could not be added (If I create VB NET project and reference to file Test.dll it OK )

View 10 Replies

Write A Unit Test Assembly In C# To Test Against An Assembly Written In VB?

Sep 20, 2011

Probably a dumb question, but can you write a unit test project in one language to test against another project in a different language?I'd like to translate one of our VB assemblies into C#, but want to build unit tests to verify the results. I've tried to set a unit test project up to do this, but I can't seem to access the VB code within a unit test... I can't figure out if I'm just missing/doing something stupid, or it really isn't allowed.

View 2 Replies

Web App To Test OS?

Jan 12, 2010

I am playing with the virtual machine version of the Google Chrome OS. I need a web app that I KNOW is made in visual basic to test to see if it will work with it or not. This will help determine if it's possible to make web apps for this Google OS in VB.

View 4 Replies

Asp.net - Test QueryString?

Apr 29, 2009

I have a query string called propID and I wanna check if the passed value in it is a legal integer or not to avoid throwing an error that might reveal info about my database, how can I do it? In other words, I want something like -but in vb.net- : IF QueryString("propID").Content.Type = "int32" Then Proceed

View 5 Replies

Self Grading Test App?

Apr 24, 2012

Create an app for the DMV that grades the written portion of the driver license exam.Theexam has 20 multiple choice questions. Here are the correct answers to the questions:1=A 2=C 3=D 4=A 5= B 6=D 7= B 8=C 9=A 10=A 11=B 12=B 13=C 14=D 15=C16=A 17=C 18=B 19=D 0=DStore the correct answers in an array. The user interface form should allow the user to enter an answer for each question.When the user clicks the Score Exam button, the application should display a message showing whether each question was answered correctly or incorrectly, and whether the student passed or failed the exam.A student must orrectly answer at least 15 of the 20 questions to pass.Input validation: Only accept letters A, B, C, and D

here is what i have so far:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

[code]....

View 4 Replies

Sql - VB -- How To Test For Value Not In Dropdown

May 11, 2011

I have a large VB/SQL application that I have created a problem in. I have a table of procedures that have an active flag on them. This flag can be toggled through a user screen. Other screens access this same table to populate dropdowns. The values are stored in the table as the ID field (PK). The problem I have is that I am selecting the dropdown values based on the Active flag. If I select a record that has a procedure stored in it that has been made inactive, I get the old Object Not Set to an Instance.... error.

What I want to be able to do is check for the value in the record when populating the dropdown and allow the record to be displayed by bypassing the SQL error and just showing the dropdown value as blank while not altering the record itself. I hope I'm making sense. Code is below.but I'm back in app programming after being a SysAdmin for 20 years and I'm still rusty.[code...]

View 1 Replies

Test File To Sql?

Jun 12, 2011

If the condition = true How do i select all records stored in .txt (temporary text file) to be updated in sql table How do i do that.

View 10 Replies

Test On Mac And Vista?

Jul 3, 2009

Can someone tell me if it works on windows Vista and Mac? And any other OS.

View 3 Replies

Test To See If Usb Device Is On?

Sep 17, 2009

How would a person test to see if a usb device is on? I have a program with a usb reader attached to it and would like to throw an exception if it is not on.

View 2 Replies

Test Whether An Entry Is Available?

Jun 16, 2011

In my program I need to test whether an entry is available I ue the following code:

If Not (westTF(Me.K) < 0) Then
If westTF(Me.K) Then
Exit Sub
End If
End If

This does not function, but when I remove the outer IF it is OK. ( I need to test otherwise an error is generated when West is exhausted).

View 6 Replies

Textboxes - How To Test For 2 Out Of Three

Sep 21, 2009

I have 3 textboxes, I want to test if user has filled out only any 2 of 3. What's a good algorithm?

View 6 Replies

.net - DataTable Sort Test?

Jul 22, 2010

I was asked this question recently in a test, which I didn't pass. For the life of me, I couldn't spot what the problem was. It's probably something really obvious as well, but even a colleague of mine couldn't spot it either. The best I could come up with was issues with bottlenecks and naming inconsistencies of parameters! I blame it on the fact I've not done any vb.net for years, I've been doing C# mostly these days

[Code]...

The question: This function, although it will successfully sort a datatable, has a major problem with it.What is the problem? Re-write the function in either C# or VB.Net using LINQ.

View 2 Replies

.net - Regex Test For NUMBERS?

Feb 28, 2009

I have found a Regex that test if the text passed to a TextBox is an email.

If Regex.IsMatch(email.Text, "^(?("")("".+?""@)|(([0-9a-zA-Z]((.(?!.))|[-!#$%&'*+/=?^`{}|~w])*)(?<=[0-9a-zA-Z])@))" + "(?([)([(d{1,3}.){3}d{1,3}])|(([0-9a-zA-Z][-w]*[0-9a-zA-Z].)+[a-zA-Z]{2,6}))$") _

[code]....

View 4 Replies

Asp.net - Use Resx With On Variable Test?

Apr 23, 2012

I've been looking for a tuto to use resx but I only found some where the resx depends on the localization(and the language of the browser).How can I tell my app to use a certain resx when a certain variable has a certain value.For instance I'd like to use default.aspx.de.resx when xyz=1.

Edit:I ve heard there's an issue to override InitializeCulture.

Public Class FormBase
Inherits Page
Protected Overrides Sub InitializeCulture()

[code]....

How could I access to Master.LanguageID in this class?

View 1 Replies

Can't Test Application.StartupPath On IDE

May 31, 2011

I work with a database, the db is on the <project_folder>database folder.

If want to open the database, Application.StartupPath returns[code]...

So I have to compile the project to an .exe to make tests.

View 4 Replies

Catch NullReferenceException Or Test For Nothing First?

Nov 12, 2010

We have a property whose job is to look up a description. If the lookup fails it should show an empty string.

So we can code the property like this:

If foo.bar Is Not Nothing Then
Return foo.bar.Description
Else

[Code]....

But are there any problems (performance, purity, other?) with just catching and ignoring the error?

You sometimes read it's expensive to throw an exception but I am not sure whether the author means it's expensive to build in exceptions using the Throw keyword (which I am not doing) or whether he means it's expensive to allow exceptions to occur (as I would be doing).

View 2 Replies

Code To Test Webcam If It's On Or Off?

Jun 10, 2009

Is there any code to test the webcam if it's on or off ?. i mean, i need a code that telling me if my webcam is on.

View 2 Replies

Convert String Into Test?

Aug 13, 2011

I am building an application to update a database.I have a Map table where row 0 holds the target table field name Row 1 holds an update value or Source table Column name Row 2 holds a Where condition eg

Map: CustNo CustName Val1 Val2
Update: 25
Where: =[CustNo] > [Fld14]

In this example I am going to update the Target Table Field 'Val1' to 25 where the Target Table Rows have Field 'Val1' data > 14 AND Target Table Field 'CustNo' = the Source Table Field 'CustNo' AND the Target Table Field 'Val1' > the Source Table Field 'Fld14' Where I am stuck is I at the moment is wondering how I should convert the strings into test conditions as I iterate the Target Table eg Say my test string is stTest and it holds " = 25" For each dr as datarow in dtTarget

some code

... stFld = "Val1"
if dr(stFld) { convert stTest into literal '=' and then 25}

... do something the only way I can think is to build up a series of test cases like:

Select stOp
Case stOp = "="
Case stOp = "<>"
etc.

View 17 Replies

Could Not Run Unit Test With Mock

Apr 18, 2012

I tried to make an unit test for this method which is pretty simple only add an object into the data base and if it works well returns true

[Code]...

View 1 Replies

Crashes App When Unning On A New Test Pc?

Jun 11, 2012

when I added code to impersonate a user it crashes my app when unning on a new test pcalso data from an access database no longer populates my list boxesso first please help me to pass credentials to teh commands I need to run on remote machines , here is my code so far...

first a new class
Imports System
Imports System.Security

[code]......

View 21 Replies

Create A Ping Test App?

May 22, 2009

I created an application using the Ping control. So far, when "Button1" is pressed, it performs a ping test to [url]... How do I create it so that it will display a message in RichTextBox1, depending on whether or not it was successful?

View 1 Replies

Creating Anagrams For A Test DB?

Mar 18, 2012

I have a SQL Server DB containing real data (e.g. Customer names, ecc).I'd like to transform it to a DB to show in presentations without showing the real names contained in there.

One solution could be to transform real names in anagrams (e.g.: a customer with name "abcdefg" could become "cfadgbe") so that original name is not too easily recognizable.If you did something similar in the past (possibly in VB.NET, but C# is ok too), (If you did something different with the same goal... then it will be OK too!)

View 2 Replies

Dns Test Fail On Correct Dns Asp.net

May 13, 2011

I do an dns test before i send mail to ensure i dont get errors.But there is a problem, when i try to send an email to an adress xxxxx@eco-log.sei get an error from the dns function. when i try to delete the "-" in the mail adress it works.at first i tohught it was because of the "-", but i made an email at zzzzzz@eh-design.se and it works like a charm, what could be the problem then? It is 100% sure that "xxxxx@eco-log.se" is an existing email/dns.The error message im getting is "No such known source"(freely translated)

Heres the dns check code:

Public Function testDNS(ByVal dnsstring As String) As Boolean
Dim email As String = dnsstring
Dim host As String() = email.Split("@")
Dim hostName As String = host(1)

[code]....

View 2 Replies







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