asp.net mvc 3 - Illegal characters in path when calling the index view from my controller -


i receiving argumentexception when invoking index action of 1 of controllers , not sure why. error message following:

server error in '/' application.

illegal characters in path.

[argumentexception: illegal characters in path.]  system.io.path.checkinvalidpathchars(string path) +126  system.io.path.combine(string path1, string path2) +38 

i not sure why happening. here code controller:

    public actionresult index()     {         var glaccounts = db.glaccounts.tostring();         return view(glaccounts);     } 

the ambiguity comes fact using string model type. ambiguity resolved this:

public actionresult index() {     var glaccounts = db.glaccounts.tostring();     return view((object)glaccounts); } 

or:

public actionresult index() {     object glaccounts = db.glaccounts.tostring();     return view(glaccounts); } 

or:

public actionresult index() {     var glaccounts = db.glaccounts.tostring();     return view("index", glaccounts); } 

notice cast object pick proper method overload there view method takes string argument represents view name cannot throw whatever want => if it's string must name of view , view must exist.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -