MVC3 ASP在hreff上发布从ASP到PHP的信息

问题描述:

在网站上,我的头上有以下代码,如果用户已经登录,那么链接“跟踪”会将用户发送到以下链接。 我怎样才能发送像customerid一样的会话信息?标题位于MVC3 ASP站点上,链接指向通过iframe内部显示的PHP站点。MVC3 ASP在hreff上发布从ASP到PHP的信息

<li class="al-contact">@if (Model.CurrentUser != null) 
     { if(Request.IsAuthenticated) 
           { 
            <a href="http://webpilot/content/TrackingSystem_order" target="_self">Tracking</a> 
            } 
            } else { 
       } 
     </li> 

CustomerID添加为您的viewmodel/base viewmodel的属性。从Session或其他地方获取它,然后将其传递给视图。在那里使用它来建立到外部网站的网址。

public class TrackingListViewModel 
{ 
    public int CustomerID { set;get;} 
    //Other relevant Viewmodel properties 
} 

在您的Action方法中设置值。

public ActionResult List() 
{ 
    var vm=new TrackingListViewModel(); 
    vm.CustmoerID=124; 
    // hardcoded for demo. you may read from session or somewhere and set it 
    return View(vm); 
} 

,并在视图中,发送的查询字符串(假设该网站的页面将读取查询字符串值,并对其进行处理,你需要知道他们期待什么样的查询字符串键,下面的示例假设将它们读键叫做“customer

@model TrackingListViewModel 

<li class="al-contact"> 
@if (Model.CurrentUser != null) 
{ if(Request.IsAuthenticated) 
    { 
     <a href="http://somewebsite/[email protected]" 
                 target="_self">Tracking</a> 
    } 
} 
</li>