I'm using Active Directory and Forms Authentication to log into a few of our intranet websites. Sometimes when users log in, an exception occurs. I receive an email on all exceptions and so far, this is the only exception that I don't know how to fix. I have researched this on and off for weeks, but I have had no luck in solving this problem.


Date and Time:
01/06/2014 8:37 AM

The server is unavailable.

Stack Trace:

at System.DirectoryServices.Protocols.LdapConnection.BindHelper(NetworkCredential newCredential, Boolean needSetCredential)
at System.Web.Security.ActiveDirectoryMembershipProvider.ValidateCredentials(String username, String password)
at System.Web.Security.ActiveDirectoryMembershipProvider.ValidateUserCore(String username, String password)
at System.Web.Security.ActiveDirectoryMembershipProvider.ValidateUser(String username, String password)
at System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e)
at System.Web.UI.WebControls.Login.AttemptLogin()
at System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Browser Information:

Browser Capabilities, Type = IE8, Name = IE, Version = 8.0, Major Version = 8, Minor Version = 0, Platform = WinXP, Is Beta = False, Is Crawler = False, Is AOL = False, Is Win16 = False, Is Win32 = True, Supports Frames = True, Supports Tables = True, Supports Cookies = True, Supports VBScript = True, Supports JavaScript = 3.0, Supports Java Applets = True, Supports ActiveX Controls = True, Supports JavaScript Version = 1.5,

I am unable to replicate this error on the development server. It's strange, because it will throw the exception, then they can log in just fine after. Some days I don't receive this exception at all, and other days it's off the wall. Could this be a problem with the production server? Possibly a setting is missing or something? I really don't know what's going on with this one. Does anyone have experience with this?

This is how I'm connecting in the web.config

Connection string

<add name="ADService" 
     connectionString="LDAP://domain/OU=users,DC=domaincontroller,DC=net" />

Membership provider

 <membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
        <clear />
        <!--Membership provider for Active Directory-->
        <add name="AspNetActiveDirectoryMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider,  System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
             connectionStringName="ADService" attributeMapUsername="sAMAccountName" />

I'm not sure what's going on. Any help is appreciated!

UPDATE: We are currently doing a big release that includes a Single Sign On. We are still using Forms Authentication and Active Directory. We set up a brand new production server. It hasn't went live yet, but some people have access to it. I have already received the same message on this new server. It's Server 2008 R2 Standard. We are using IIS Version 7.5.7600.16385 to be exact. This exception is annoying for me and annoying for the users. It may not happen all the time on the current production but some days it doesn't happen once (not sure if it's because it's a slow day and people aren't using the website) and then some days it happens like crazy and I can get about 15 to 20 of theses exceptions. (if not more) I have looked at multiple issues. Others have had a similar problem but theirs occur when they enter the correct username but wrong password. I have tried entering the password in wrong hundreds of times but I could never replicate the problem.

I am trying to write an extension method which will be used inside a razor view to get the file path to said view.

I have tried putting the extension method on HtmlHelpers<T> and NancyRazorViewBase but cannot seem to get the correct information from the view or from the render context e.g.

public static string GetPath(this NancyRazorViewBase view)
    //Is null, expecting something like C:\app\views\index.cshtml
    return view.Path;

<input type="hidden" value="@this.GetPath()"/>

Is it possible to get the path to the current view from inside the view?

I am using Nancy 0.23.

Recently I decided to start developing a client/service based system using WCF and a Duplex Channel (callbacks from Service to client). The clients will behave as "slaves", that is, they will only connect to server and from then on, only the server communicates with them. Eventually the server may request that the clients send "data streams" to him (frequent updates of new content/objects).

I want to make my software as loosely coupled as possible, but even reading about the different patterns for this, such as MVC and MVP, they don't seem to be designed to fulfill my specific requirements.

What is the best code architecture or pattern for my problem? Considering the technologies I am using.

This question already has an answer here:

Hello StackOverflow members,

I have two controllers:

public class FirstController : Controller
    public string Index()
        return "FirstController - Index";

public class SecondController : Controller
    public string Index()
        return "SecondController - " + language;

And I have two URLs: 1. mysite.com/ 2. en.mysite.com/

I expect to get:

  1. FirstController - Index

  2. SecondController - en

where en can be any param.

How should I adjust my Global.asax to fix this issue:

public class MvcApplication : System.Web.HttpApplication
    protected void Application_Start()

    public static void RegisterRoutes(RouteCollection routes)

            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

I have added added Entity Framework to my project and selected Code first from database when creating my models. But the problem is, i couln't find how find how to update existing models and add new models to my project when i make changes on database.

I'm designing an ASP.NET MVC website for browsing photos.

I need advice on what's the best way to implement navigation between photos in a particular category. Most obvious way to do it for me is to use urls like myphotosite.com/photos/animals/1 and when a visitor clicks "next" button, a GET request is made for the next photo (myphotosite.com/photos/animals/2).

Benefits of this approach is that it will work with JavaScript disabled, each photo has a link which can be shared, bookmarked or indexed by search engines. Another design I thought of is to save an array of image urls on the page and dynamically change src attribute of images when visitor clicks next button on the client.

It'll be more fluid and less workload for the server, but as I understand it doesn't have the advantage of each photo having a unique url. I'll appreciate any advice from more experienced people.

I have a solution that I built using Webforms that passes over approximately 10 fields to the Realex payments processor server (I use the redirect method), and all works fine there. I'm brand new to MVC and am trying to put in place the same functionality using MVC as I currently have set up with Webforms. With my Webforms solution, I use a buttonclick event handler and a Postback URL, to gather the data I need to pass to Realex and the URL is managed in the Postback.

Using MVC, I don't seem to have the use of an event handler or a Postback URL declaration, or if I do, I can only post back to the form, whereas I need to post my data to an external website.

So in my MVC controller, I have hardcoded in the values (for testing purposes), that I am trying to pass to Realex.

The last line above (return Redirect), is bringing me to the Realex page (it is not letting me see the boxes though for entering credit card details, instead it is returning a 506 error saying "Invalid MerchantID or account number)...

I've been onto Realex and they are telling me that they can see the data above that I'm trying to pass to their server, like my account ID, my order reference, etc.

I've also tried doing it this way within my View, just to get this to post properly:

    <input id="ORDER_ID" name="ORDER_ID" type="hidden" value="6264286038162642860381" />
    <input id="ACCOUNT" name="ACCOUNT" type="hidden" value="XXXXXXXXX" />
    <input id="AMOUNT" name="AMOUNT" type="hidden" value="100" />


But I don't know how to hook up my form fields with my controller, I know I'm still thinking "Webforms" here, and am just not thinking MVC, because I've so little experience with MVC and am finding the transition to MVC more difficult than I though.

Thanks in advance for any help with this...

![This is My view controller connection looks][1]


![I have to go from view controller A to VC-B through programatically, Because it should satisfy login authentication based on device ID. Let me Explain Clearly. When user installs my app he should set up his email and verify.After verification He should move to VC-B.After moving VC-B, Viewcontroller-A should not open again when he opens app again. Something like kill View controller-A, and load VC-B whenever he opens app.

Question1- How to kill View controller-A completly.

Second thing i do not want to show navigation bar On View controller-A, But on View VC-B,VC-C and VC-D so on. i want to show navigation bar because user should be able to move back and forth.That's the reason i added navigation controller before VC-B again.

If i'm not able to show Navigation bar on VC-B until i enable show navigation bar on Navigation controller before View Controller A.

Question2-How to enable Navigation bar on VC-B but not on Viewcontroller-A.

][1] This is the code how am i moving from View controller A to VC-B.

    if (alertView.tag == 99) {
    if(buttonIndex == 0){
    VC-B *vcb =
    [self.storyboard instantiateViewControllerWithIdentifier:@"VC-B"];
      [self.navigationController pushViewController:vcb animated:YES];

} } Help me to point Right direction.

How to use this in a mvc project ???


the truth I am new to programming would greatly help your comments


Am I correct in understanding, that at the high-level, when operating with a .xib or .storyboard, the model-view-controller paradigm is structured so that the .xib or .storyboard is the view, which the .h of the UIViewController file is the model and the .m is the controller? Is this just a very basic way of understanding the connection with a model-view-controller structured program, or am I getting this all wrong?

I am learning MVC and was wondering about a particular problem that I have came across, below is my code from one of controller's methods.

public function psn($params) {

    # There are parameters supplied - we are getting a single item
    if ($params) {

    # There are no parameters supplied - show all items
    } else {


As you can see above the method psn can allow parameters to fetch a single item or if no parameters are defined it will fetch all items.

Am I doing this correctly? It is almost as if the psn method needs both an index method and a get item method but I am kinda putting it into one method.

How would I go about doing this? Would multiple controllers be an idea that would be plausible?



Would it be plausible to do something like below;

public function psn($params) {

    # There are parameters supplied - we are getting a single item
    if ($params) {

         # Call private method psnGetOne

    # There are no parameters supplied - show all items
    } else {

         # Call private method psnGetAll

I have created a mySQL table: student.studentInfo with:-

Int id autofill PK, 
 String name, 
int age,  
String email.

User fills up a StudentRegForm and The values of name, age and email are shown on a RegisteredStudent jsp.

I want to display contents [data elements] of the mySQL table on a jsp page.

My StudentDaoImpl :-

public class StudentDaoImpl implements StudentDao {

    DataSource datasource;
    private JdbcTemplate jdbcTemplate;

    public void setDataSource(DataSource datasource) {

        this.datasource = datasource;
        this.jdbcTemplate = new JdbcTemplate(datasource);


    public List<Student> getStudentList() {

        List<Student> studentList = new ArrayList<Student>();
        String sql = "select * from student.studentInfo";
        JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource);
        studentList = jdbcTemplate.query(sql, new StudentMapper());
        return studentList;


The above StudentMapper method is:

public class StudentMapper implements RowMapper<Student>{

    public Student mapRow(ResultSet rs, int rowNum) throws SQLException {

        Student student = new Student();
        student.setId( rs.getInt("id"));

        return student;


View Resolver is set on MvcConfiguration and DataSource props are declared as @Bean :-

@ComponentScan(basePackages = "com.anand")
public class MvcConfiguration extends WebMvcConfigurerAdapter {

    public ViewResolver getViewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        return resolver;

    public void addResourceHandlers(ResourceHandlerRegistry registry) {

    public DataSource getDataSource() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();

        return dataSource;


Students fill up this Studentform.jsp:-

<form   action="StudentAddSuccess.htm" method=post>
id <input type="text" name="id" />
Name <input type="text" name="name"/>
Age <input type="text" name="age" />
Email <input type="text" name="email" />

<input type="submit" name="submit" value="save">


Controller class is:

public class StudentController {    
    StudentDao stdDao;  
    @RequestMapping(value = "/studentForm.htm", method = RequestMethod.GET)
    public ModelAndView sendStudentForm() {
        ModelAndView mav = new ModelAndView("studentForm");
        mav.addObject("formHeading", "Student Registration Form");
        System.out.println("student Form");
        return mav;
    @RequestMapping(value = "RegdSuccess", method = RequestMethod.POST)
    public ModelAndView addStudent(@ModelAttribute("student1") Student student1) {
        ModelAndView mav = new ModelAndView();
        //mav.addObject("studentId", "id is:-" + student1.getId());
        mav.addObject("studentName", " name is:- " + student1.getName());
        mav.addObject("studentAge", " age is:-" + student1.getAge());
        mav.addObject("studentEmail", "student email is:-" + student1.getEmail());
        // mav.addObject("student", "student list is"+ student1);
        System.out.println(" hello  from RegdSuccess");
        return mav;

@RequestMapping( value = "RegdStudent", method = RequestMethod.GET)
        public ModelAndView showStudent(@ModelAttribute("std")Student std) throws IOException{
            ModelAndView mav = new ModelAndView();
            List<Student> listStudent= stdDao.getStudentList(); 
            mav.addObject("msg", "hello from Regd jsp");
            //mav.addObject("listStudent", listStudent);

            System.out.println(" hello  from Regd Students controller"+std.getName());

        return mav;

StudentDao is:

public interface StudentDao {   

    // create
    public void createStudent(Student student);

    // read
    public Student getStudent(Integer id);

    // Update
    public void updateStudent(Student student);

    // delete
    public void deleteStudent(Integer id);

    // List

    public List<Student> getStudentList();

    // save

    public void save(Student student);


And StudentImplDao is:-

public class StudentDaoImpl implements StudentDao {

    StudentDaoImpl StudentDao;  
    DataSource datasource;
    private JdbcTemplate jdbcTemplate;

    public void setDataSource(DataSource datasource) {

        this.datasource = datasource;
        this.jdbcTemplate = new JdbcTemplate(datasource);

    public void doExecute() {
        String sql = "SELECT * FROM STUDENT.StudentInfo";
        SqlRowSet srs = jdbcTemplate.queryForRowSet(sql);
        int rowCount = 0;
        while (srs.next()) {
            System.out.println(srs.getString("id") + "-"
                    + srs.getString("name") + "-" + srs.getString("age") + "-"
                    + srs.getString("email"));

        System.out.println("Number of records" + rowCount);

    // -------------List----------------------------------------
    public List<Student> getStudentList() {

        List<Student> studentList = new ArrayList<Student>();
        String sql = "select * from student.studentInfo";
        JdbcTemplate jdbcTemplate = new JdbcTemplate(datasource);
        studentList = jdbcTemplate.query(sql, new StudentMapper());
        return studentList;

 // other remaining methods of StudentDao go here for the implementations

I can input name,age, email on the Studentform.jsp and those inputs are displayed on RegdSuccess.jsp, but my RegdStudent.jsp page is not displaying list records from my database as I want it to. RegdStudent.jsp is:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>

<title>Regd. Students</title>
    hello from Regd Students jsp 

        <c:forEach items="${msg}" var="employee">
                <td><c:out value="${employee.id}" /></td>
                <td><c:out value="${employee.name}" /></td>
                <td><c:out value="${employee.age}" /></td>
                <td><c:out value="${employee.email}" /></td>


I would like to have this jsp age show all the records from the mysql database.

What is wrong? And where?

I have such file structure in my node.js app:

  • app
    • models
      • user
      • book
    • controllers
      • user
      • book
    • views
      • user
      • book

I want to make my app modular. How can I interact with book controller from user controller? I know about require(...), but is there any smart way to do it? So my target is to make many modules (user, book, article, news, etc.), and easily on/off any of these without affecting others (like PHP CMS - Joomla, Wordpress, etc.)

I am having some issues with a concept and was looking to get some feedback on what was going wrong. Basically I am looking to create a NSObject that holds all of the core UI elements in my application that are to be used over and over to reduce the amount of code I write and also to help save on memory. For example, if there are particular UIImageViews, UILabels, and UIViews that are consistent throughout all UIViewControllers. I can then create my NSObject as part of my Model and then add UIViews from my custome UI class where ever I need them to local UIViewControllers. So far, this idea is working well, but when I move backwards between between UIViewControllers in my stack sometimes, not all the time I experience UIImageView not displaying images at all. The view is still on the stack, but it's like the image is gone? This is where I have been running into issues. Has anyone ever tried something like this or has anyone ever experienced anything like this?

I have a partial view which is loaded into JQuery UI Dialog. All the data annotations are firing as expected. But custom validations are not firing.

Model Object:

Public class Model
     public IEnumerable<SelectListItem> Primary { get; set; }


            public string SelectedPrimaryID { get; set; }

            public IEnumerable<SelectListItem> Secondary { get; set; }

            [TwoFieldCompare("SelectedPrimaryID", ErrorMessage = "X and Y cannot be same.")]

            public string SelectedSecondaryID{ get; set; }

Client Validation: Debugger is hitting this method

public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)


            var rule = new ModelClientValidationRule()


                ValidationType = "twofieldcompare",

                ErrorMessage = this.ErrorMessage


            rule.ValidationParameters.Add("dependentproperty", dependentProperty);

            yield return rule;   


In customJquery file, I added below code:

// Data Annotation client side



          function (value, element, params) {

              var dependentProperty = params.dependentProperty;


            // Check for the condition and return true or false


        'twofieldcompare', ['dependentproperty'],

        function (options) {

            var params = {

                dependentProperty: options.params.dependentproperty

            options.rules['twofieldcompare'] = params;

            options.messages['twofieldcompare'] = options.message;



debugger is not hitting the client side validation.

All the Jquery libraries are referred as a bundle in Master Layout.

Do I need to add any additional reference to make the client side data annotation work in Jquery UI Dialog?

Thanks in advance for your help.

i have a question regarding the JavaFX UI Controllers, So i have the following structure:

<VBox : "The Home Object Node"> 
   <AnchorPane : "The Floor Object Node">
      <FlowPane : "A Container in the Floor to Arrange Rooms">
          <AnchorPane : "The Room Object Node">
             <FlowPane : "The Container of the Object Inside A Room">
               <AnchorPane : "The Container for every object in the Room">
                 <ImageView> : "A pic of the "whatever""">

actually i can not understand the relationship between parent and children regarding computing the size. so i have a problem when i re-size on of the children let us say a "Room" the Parent which is Floor does not re-size it self in Favor of the Child. here is an image: I COULDN'T POST THE IMAGE "OVERFLOW ROLES".....!!!!!!!!!!

I am Sorry if i am missing any needed info, plz tell me what you need and i will provide it to you thanks in advance regards

For some reason, I am getting null value returned for Princ_Comments field, but it contains data. What could be the problem?

Json Output:

[{"ID":"ACL","Name":"A.C. Lyau Company","Princ_Comments":null}]


    public class PrincComments
    public string ID { get; set; }

    public string Name { get; set; }

    public string Princ_Comments { get; set; }


            public JsonResult GetHTML5Json_PrincComments(string id)
                 id = "ACL";                    
                var result = db.Database.SqlQuery<PrincComments>("Select [ID], [Name], [Princ Comments] From View_Principle_Active where ID = '" + id + "'");                

                return Json(result, JsonRequestBehavior.AllowGet);

How can I download a file from web (e.g. a pdf file - http:/addons.cursecdn.com/files/612/825/SC1_Remake_Installation_Guide.pdf) to the client in MVC? What I tried:

    public FileResult Download()
        const string name = "http://addons.cursecdn.com/files/612/825/SC1_Remake_Installation_Guide.pdf";
        const string type = "application/pdf";

        return new FilePathResult(name, type)
            FileDownloadName = "SC1_Remake_Installation_Guide.pdf"

This is giving me only the error message that it 'is not a valid virtual path'..

I have method in which I grab all data from db and pass it to the view. That's ok, and then in view I can $location->ip (for grabbing location from that specific user), but I'm trying to fetch string in controller, put it in this variable

$location = GeoIP::getLocation($getIp);

and then pass that variable in view. How can I do that?

I ran into a problem, and I hope you can help me solve it.

I have a form with several fields in it, few of them validated remotely.

@using (Html.BeginForm("Action", "Controller", new { id = "myForm" }))
                <td width="225">Work permit/Registration card:</td>
                <td>Start date: @Html.EditorFor(m => m.WorkPermitStart)</td>
                <td width="50"></td> 
                <td>End date: @Html.EditorFor(m => m.WorkPermitEnd)</td> 
                <td>@Html.ValidationMessageFor(m => m.WorkPermitEnd)</td>
<li><button type="submit" value="submit" class="form-yes">submit</button></li>

piece of code like this works just fine, when WorkPermitEnd input loses focus the remote validation is done, and in case the fields are invalid, the message is shown in the following table cell as expected.

My problem is, I need to change it and put the validation message outside the form itself, in completely different section. And this is where I struggle to find a suitable solution, as when losing formcontext, the

@Html.ValidationMessageFor(m => m.WorkPermitEnd)

just won't work and doesn't show the validation message for the input, that is in the original form. So my question is, is there some way to pass the validation message to different section on the page?

EDIT: added layout of the page

<section id="content">

<aside id="messages">
    <aside id="validation">
        @RenderSection("ValidateMessage", required: false)
    <aside id="help">
        @RenderSection("Help", required: false)

hello guys i am facing issue and i cant understand whats the problem i am rendering partial view using jquery ajax call to get the partial html and append it on the main page but there is strange thing happen its return full main page html not the partalial view html only and of course that make in each click for jquery event dublicat all controls in my main page

i'd like to share my code with u my u can explain why that happen and how i can fix it that page is a multi insertion for model call staff model

Main Page Razor code

 @model IEnumerable<Overtime.Models.staffmodel>

<div class="row">

    <div class="col-xs-12">

        @using (Html.BeginForm())

            <div id="mytblcontainer">
                    @foreach (var item in Model)

                        Html.RenderPartial("_Create2", item);


        <i class="fa fa-plus-square add" id="addItem"></i>

        <br />
            <input type="submit" value="أضافة" class="btn btn-primary btn-lg" />

        <div class="pull-left back">
            @Html.ActionLink("العودة الى الرئيسية", "Index")
            <i class="fa fa-arrow-circle-o-left"></i>



partial view razor code

  @model Overtime.Models.staffmodel

@using Overtime.Helpers

@using (Html.BeginCollectionItem("staff"))
    <div class="EditRow">
        الأسم :
        @Html.TextBoxFor(model => model.staffName, new { @class = "form-control" })

        الترتيب :
        @Html.TextBoxFor(model => model.staffOrder, new { @class = "form-control" })

        <i class="fa fa-times eleremove   faa-wrench animated-hover animated-hover"></i>


partial view Controller

  public PartialViewResult BlankEditorRow()
            return PartialView("_Create2", new staffmodel());


$("#addItem").click(function (e) {

        url: "Create/BlankEditorRow",
        cache: false,
        success: function (html) {

    return false;

BeginCollectionItem custom html helper

public static class HtmlPrefixScopeExtensions
    private const string idsToReuseKey = "__htmlPrefixScopeExtensions_IdsToReuse_";

    public static IDisposable BeginCollectionItem(this HtmlHelper html, string collectionName)
        var idsToReuse = GetIdsToReuse(html.ViewContext.HttpContext, collectionName);
        string itemIndex = idsToReuse.Count > 0 ? idsToReuse.Dequeue() : Guid.NewGuid().ToString();

        // autocomplete="off" is needed to work around a very annoying Chrome behaviour whereby it reuses old values after the user clicks "Back", which causes the xyz.index and xyz[...] values to get out of sync.
        html.ViewContext.Writer.WriteLine(string.Format("<input type=\"hidden\" name=\"{0}.index\" autocomplete=\"off\" value=\"{1}\" />", collectionName, html.Encode(itemIndex)));

        return BeginHtmlFieldPrefixScope(html, string.Format("{0}[{1}]", collectionName, itemIndex));

    public static IDisposable BeginHtmlFieldPrefixScope(this HtmlHelper html, string htmlFieldPrefix)
        return new HtmlFieldPrefixScope(html.ViewData.TemplateInfo, htmlFieldPrefix);

    private static Queue<string> GetIdsToReuse(HttpContextBase httpContext, string collectionName)
        // We need to use the same sequence of IDs following a server-side validation failure,  
        // otherwise the framework won't render the validation error messages next to each item.
        string key = idsToReuseKey + collectionName;
        var queue = (Queue<string>)httpContext.Items[key];
        if (queue == null)
            httpContext.Items[key] = queue = new Queue<string>();
            var previouslyUsedIds = httpContext.Request[collectionName + ".index"];
            if (!string.IsNullOrEmpty(previouslyUsedIds))
                foreach (string previouslyUsedId in previouslyUsedIds.Split(','))
        return queue;

    private class HtmlFieldPrefixScope : IDisposable
        private readonly TemplateInfo templateInfo;
        private readonly string previousHtmlFieldPrefix;

        public HtmlFieldPrefixScope(TemplateInfo templateInfo, string htmlFieldPrefix)
            this.templateInfo = templateInfo;

            previousHtmlFieldPrefix = templateInfo.HtmlFieldPrefix;
            templateInfo.HtmlFieldPrefix = htmlFieldPrefix;

        public void Dispose()
            templateInfo.HtmlFieldPrefix = previousHtmlFieldPrefix;

thanks in advanced and hope some body tell me why that happen