473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Can I solve this? (?:)

Hello,

I have the following:

return returnUrl == null ? RedirectToAction("Index", "Home") : Redirect
(returnUrl);

I get an error:

Type of conditional expression cannot be determined because there is
no implicit conversion between 'System.Web.Mvc.RedirectToRouteResult'
and 'System.Web.Mvc.RedirectResult'

Is there a way to fix this without needing to use an IF?

Thanks,

Miguel
Nov 20 '08 #1
2 2532
On Nov 20, 6:26*pm, "Michael B. Trausch" <m...@trausch.uswrote:
On Thu, 20 Nov 2008 09:46:12 -0800 (PST)

shapper <mdmo...@gmail.comwrote:
I have the following:
return returnUrl == null ? RedirectToAction("Index", "Home") :
Redirect (returnUrl);
I get an error:
Type of conditional expression cannot be determined because there is
no implicit conversion between 'System.Web.Mvc.RedirectToRouteResult'
and 'System.Web.Mvc.RedirectResult'
Is there a way to fix this without needing to use an IF?

I'd use an 'if' statement here, for readability---if statements are
easier to quickly parse with your head when compared to (most) usages
of the ternary operator. *IMHO, the ternary operator should only be
used with either a variable or a literal for the possible return
values, and function calls should be done in if statements.

It looks as if you're in need of parenthesis. *Try:

return((returnUrl == null) ? RedirectToAction("Index", "Home") :
* Redirect(returnUrl));

If you're still getting an error, then you probably need casts to
something that makes sense within the context of your code.

* * * * --- Mike
Thanks!
Nov 20 '08 #2
shapper wrote:
Hello,

I have the following:

return returnUrl == null ? RedirectToAction("Index", "Home") : Redirect
(returnUrl);

I get an error:

Type of conditional expression cannot be determined because there is
no implicit conversion between 'System.Web.Mvc.RedirectToRouteResult'
and 'System.Web.Mvc.RedirectResult'

Is there a way to fix this without needing to use an IF?

Thanks,

Miguel
Just cast one or both of the result operands to the data type of the
return value.

--
Göran Andersson
_____
http://www.guffa.com
Nov 21 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Oracle3001 | last post by:
Hi All, I am looking to use SVD to solve an equation of the form Aa = B, where a is 1 row x 11 col A is 2 rows x 11 col B is 2 rows x 1 col I know from the information I am reading I need...
17
by: Just | last post by:
While googling for a non-linear equation solver, I found Math::Polynomial::Solve in CPAN. It seems a great little module, except it's not Python... I'm especially looking for its poly_root()...
27
by: Alf P. Steinbach | last post by:
I'm writing a little piece on pointers, to be "bundled" with my attempted correct C++ tutorial (see FAQ item 29.20, yes, I've finally started to at least think about that again), and while thinking...
0
by: Jitesh | last post by:
I am facing a problem in webservice, I want to know what will be the exact procedure to solve the problem............. What I want to do............ I have a table named order in SQL Server....
8
by: vj | last post by:
Hi all, I want to solve the two equations u*tan(u)=w and u^2 + w^2=V^2, where V is a known constant, and u and w are the two unknowns to be determined. Please can someone suggest me how to...
1
by: arun | last post by:
Query is too complex -------------------------------------------------------------------------------- Hi, I was trying to solve this problem since last two days but couldn't find any solution. ...
17
by: Michael Reichenbach | last post by:
Here is the example code. int main(int argc, char *argv) { string Result; WIN32_FIND_DATA daten; HANDLE h = FindFirstFile(TEXT("c://test"), &daten); system("PAUSE"); return EXIT_SUCCESS; }
2
by: beambohus | last post by:
please how do i solve this........ To write an algorithm to solve quadratic equation using almighty formular. please your respond will very much appreciated
7
by: akmaRudiliyn | last post by:
Hai everybody :). I have problem and need help. ERROR: ERROR Violation of PRIMARY KEY constraint 'PK_Table1_01'. Cannot insert duplicate key in object 'dbo.table1'. ERROR The statement has...
4
by: Kelie | last post by:
Hello group, Is there any packages in Python that will help me solve functions similar to this: x = a*(1+bx)**2.5-c where a, b, c is known and the task to solve x? Thank you, Kelie
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.