开发者

Cannot access local var in action filter: object does not contain a definition for error

开发者 https://www.devze.com 2023-02-09 12:09 出处:网络
Noob to MVC question!Consider t开发者_运维技巧he following I\'m using for an action filter public override void OnResultExecuting(ResultExecutingContext filterContext)

Noob to MVC question! Consider t开发者_运维技巧he following I'm using for an action filter

public override void OnResultExecuting(ResultExecutingContext filterContext)
{
    var model = filterContext.Controller.ViewData.Model;
}

var model contains a section I want to access. I know it's there because when I breakpoint at that point I can see.

Cannot access local var in action filter: object does not contain a definition for error

However, when i want to :

string tempStr = model.Companydetails.Address; 

I get ' object does not contain a definition ' error. Any thoughts to what im missing here. Thanks in advance for your time.

S

EDIT: @Leniel Macaferi. Scr shot!

Cannot access local var in action filter: object does not contain a definition for error


Wouldn't it be:

string tempStr = model.CompanyDetails.Address1;

I can see that Address1 is null. I cannot see the Address property. Can you confirm that there is an Address property?

The error: object does not contain a definition for, generally is related to wrongly typed variable names in your code. Note that you're using in your code Companydetails when it should be CompanyDetails with an upper case D in Details.

0

精彩评论

暂无评论...
验证码 换一张
取 消