Folks, I have a web site (asp.NET & MVC) that is implemented using NHibernate 3.X. I have manually updated NHibernate.Search to bring it up to date with that version of NHibernate and a more recent version of Lucene.net but I am having constant performance issues with Lucene. I'd like to move towards a SOLR implementation but looking at the current codebase, the NHibernate plugin/library is deprecated and documentation is sparse.

I am using overridden NHibernate listeners to decide when to inject data into the lucene index (as my entities do not (a) put all their info into the index and (b) only enter/leave the index depending on their state (all for data security). My question is, does anyone have a good working example of how I'd implement the same kind of listener behavior on solrNET instead of lucene and NHibernate.search?

Thanks in advance...

I have an application that uses IIS 7.5X and Visual Studio 2013 and it works fine in IIS Express. I have had to make changes to allow authentication and allow 32-bit but it still doesn't work on IIS, only IIS express.

I have tried to use the publish in VS2013, but that doesn't seem to work.

Is there anyway I can find the settings used by IIS express so I can set IIS up so it works the same?

Where do I setup logs? Thanks in advance for not closing this question!

Pete

I have created one WCF service that will upload the file. and after using that service I am trying to upload the file I am able to successfully upload the file but there is some issue with the FILESTREAM class.

The moment i clicked the button to upload the file when i checked by debugging the application i get to know that stream object is null. I am passing the object of stream class to the WCF method. But due to some issue that stream object is getting null. due to that null object of stream class, image which is uploded getting empty in my folder

This is my code that I am using to upload the file

 if (FileUpload1.HasFile)
        {
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(FileUpload1.PostedFile.FileName);
            FileTransferServiceReference.ITransferService clientUpload = new FileTransferServiceReference.TransferServiceClient("BasicHttpBinding_ITransferService");
            FileTransferServiceReference.RemoteFileInfo uploadRequestInfo = new RemoteFileInfo();


            string Path = System.IO.Path.GetDirectoryName(FileUpload1.FileName);

            using (System.IO.FileStream stream = new System.IO.FileStream(FileUpload1.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                uploadRequestInfo.FileName = FileUpload1.FileName;
                uploadRequestInfo.Length = fileInfo.Length;
                uploadRequestInfo.FileByteStream = stream;
                clientUpload.UploadFile(uploadRequestInfo);
            }
        }

Code for WCF Service

public RemoteFileInfo DownloadFile(DownloadRequest request)
        {
            RemoteFileInfo result = new RemoteFileInfo();
            try
            {
                // get some info about the input file
                string filePath = System.IO.Path.Combine(@"c:\Uploadfiles", request.FileName);
                System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath);

                // check if exists
                if (!fileInfo.Exists) throw new System.IO.FileNotFoundException("File not found", request.FileName);

                // open stream
                System.IO.FileStream stream = new System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);

                // return result

                result.FileName = request.FileName;
                result.Length = fileInfo.Length;
                result.FileByteStream = stream;
            }
            catch (Exception ex)
            {

            }
            return result;

        }


        public void UploadFile(RemoteFileInfo request)
        {
            FileStream targetStream = null;
            Stream sourceStream = request.FileByteStream;


            string uploadFolder = @"C:\upload\";
            if (!Directory.Exists(uploadFolder))
            {
                Directory.CreateDirectory(uploadFolder);
            }

            string filePath = Path.Combine(uploadFolder, request.FileName);

            using (targetStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                const int bufferLen = 65000;
                byte[] buffer = new byte[bufferLen];
                int count = 0;
                while ((count = sourceStream.Read(buffer, 0, bufferLen)) > 0)
                {
                    targetStream.Write(buffer, 0, count);
                }
                targetStream.Close();
                sourceStream.Close();
            }
        }
    }

I developed a rest api using ASP.net web api. When I deploy this rest api on iis, I need to create it as a web application under an asp.net web site. When I was deploying the rest api as a new web site in iis, then things worked fine. I was using the following Route api/{controller}/{id}.
When I created the rest api as a web application underneath asp.net web site project, I named the web application as api. I can't access the api methods now. Can someone point what I do wrong?

Hopefully a quick answer.

How can i edit an item in a ListView control which is nested inside a Repeater control? I've posted me code example below.

Say i have the following html:

<asp:Repeater runat="server" ID="Repeater1" 
    onitemdatabound="Repeater1_ItemDataBound">
    <ItemTemplate>
        <h1><%# Eval("Name") %></h1>
        <asp:ListView runat="server" ID="ListView1" OnItemEditing="ListView1_OnItemEditing">
            <ItemTemplate>
                <p><%# Eval("Name") %></p>
                <asp:Button Text="Edit" runat="server" CommandName="edit" CommandArgument="edit" />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="townName" runat="server" Text='<%# Eval("Name") %>'></asp:TextBox>
                <asp:Button Text="update" runat="server" />
            </EditItemTemplate>
        </asp:ListView>
    </ItemTemplate>
</asp:Repeater>

The code behind i have is:

public List<country> countries = new List<country>();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<town> tmp = new List<town>();
            tmp.Add(new town { name = "swindon" });
            tmp.Add(new town { name = "Londin" });


            countries.Add(new country() { name = "england", towns = tmp });

            tmp = new List<town>();
            tmp.Add(new town { name = "Paris" });
            tmp.Add(new town { name = "Niece" });

            countries.Add(new country() { name = "france", towns = tmp });

            tmp = new List<town>();
            tmp.Add(new town { name = "Florida" });
            tmp.Add(new town { name = "Ohio" });

            countries.Add(new country() { name = "usa", towns = tmp });


        }
        BindRepeater();
    }

    private void BindRepeater()
    {
        Repeater1.DataSource = countries.ToList();
        Repeater1.DataBind();
    }

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        ListView lv = (ListView)e.Item.FindControl("ListView1");
        lv.DataSource = ((country)e.Item.DataItem).towns.ToList();
        lv.DataBind();
    }

    protected void ListView1_OnItemEditing(object sender, ListViewEditEventArgs e)
    {
        ListView lv = (ListView)sender;
        lv.EditIndex = e.NewEditIndex;
        lv.DataBind();
    }
}

How can i actually get the ListView (which is a child of the repeater) in to edit mode so i can edit their items? The code i have at the moment simply blanks out all of the bound data on second click but does turn the ListView into edit mode (but doesn't contain any values which i set via the eval).

Hope this makes sense and hope someone can help, driving me crackers.

Thanks.

The private font that I am trying to use in my pdf is not displaying as it should. I have looked at the PDF sharp sample on their wiki, as well as examples online, but cannot get it to display with the custom font. Can anyone see anything wrong with the code below?

    PrivateFontCollection pfc = new PrivateFontCollection();

    pfc.AddFontFile(Server.MapPath(@"~\Content\Fonts\Exo-Regular.ttf"));
    XPdfFontOptions opt = new XPdfFontOptions(PdfFontEmbedding.Default);

    //I have tried both of these options:
    XFont pdfFont = new XFont(pfc.Families[0], 12, XFontStyle.Regular, opt);
    XFont exoFont = new XFont("Exo", 12);

    gfx.DrawString("Did you receive the product as ordered?", exoFont, XBrushes.Black, 50, 45, XStringFormats.Default);
    gfx.DrawString("Did you receive the product as ordered?", pdfFont, XBrushes.Black, 50, 60, XStringFormats.Default);

I am currently working on a ASP.NET project which involves assigning various permissions based on user's roles. As we know, ASP.NET itself provides a mean to manage user roles. The table, aspnet_Roles, is used to stored user defined roles, e.g. administrator, manager, etc.

In my case, there are 15 various roles already added into this table. So I am just wondering if I should stick with using aspnet_Roles table and continue adding more roles there, or perhaps should create my own Roles table and manage them separately? I am not sure if there would be any potential issues if I customize aspnet_Roles table, e.g adding new columns, increase column length, etc.

aspnet_Roles table can probably do the job, but just seems to be a bit basic and not very scalable in my opinion. The upside of it is that those Role Provider APIs are already there and I don't need to reinvent the wheel.

So what'd be the best choice here? Any suggestions?

Thanks

I am using this code to post value of selected item from the view to the controller

@using (Html.BeginForm())
{
        @Html.DropDownListFor(model => model.MyVar, (SelectList)ViewData["List"])
        <button name="Button" value="Valider">Valider</button>

}

Is there a way to send the value when the selection change in the select list (without the need to click on the button) ?

I am trying to set up TeamCity with a single project to start with.

Everything seems to work well except for when I add an “Inspections (.NET)” build step. I am getting a Module 'C' should be referenced error every time there is an @ in a .cshtml file.

How can I configure TeamCity to work correctly with .cshtml?

I'm trying to build a query to get the numbers of rows that have the same data on a column (my column is ESTADO).

 var db = Database.Open("MyDB");
 var selectedData = db.Query("SELECT COUNT (*) FROM graficos WHERE ESTADO='FECHADO'");

 var data = db.QueryValue(selectedData);

But when i try to run it gives the following error:

Compiler Error Message: CS1502: The best overloaded method match for 'WebMatrix.Data.Database.QueryValue(string, params object[])' has some invalid arguments

Line 51:      var data = db.QueryValue(selectedData);

I am using VS2012 ultimate and already clicked "show line numbers" option from text editor. VS2012 shows line numbers in models and controllers.

I know there is a way you can show line numbers with notepad++ or browser's source code. But copy, paste and search line number process is giving waste of time and also you can't do commands like "go to definition", "peek definition" vs.

Due to these reasons, I want to show line numbers in .cshtml file

I have an umbraco 7.1 website and I use its own membership system.I can easily log in,see my status,even change password BUT there is no logout command and I don't know what method I should use for umbraco 7 to logout current user.I know i can clear the cookie and member identity but it always gives a runtime error. Help me! :D

I am trying to create a number of text box dynamically in my Razor view. How can I ensure a different id is assigned to each of the text box dynamically? My objective is to access the numeric value entered in the dynamic textbox (QuestionCount) and calculate the sum of values entered.

Below is the part of code used in my view.

                            @foreach (var QP_Count in ViewBag.NonUniformTempCount)
                            {
                                var str = @ViewBag.NonUniformTempNames[tempindex];
                                <b>@str</b>
                                for (int QCount = 1; QCount <= QP_Count; QCount++)
                                {
                               **<br /> <b>@QCount               </b>  <b>@Html.TextBox("QuestionCount")</b>**                           

                                }
                                tempindex++;
                            }

I have ASP.NET MVC app which works good on my local server. When I'm deploying it into Windows Server 2008 Standard in IIS (v7.0) the app is running property (I can see panel to log in), but when I want to log in, I have such error. I have also page Contact and when I want to run it I have the same error.
I add Model.edmx using ADO.NET Entity Data Model.

The code is simple:

In controller:

private ImportEntities Entity = new ImportEntities();
public ActionResult Contact()
    {
        var dane = Entity.Contact.FirstOrDefault();
        return View("Contact",dane);
    }

Connection string in Web.config:

<add name="ImportEntities" connectionString="metadata=res://*/Models.Model.csdl|res://*/Models.Model.ssdl|res://*/Models.Model.msl;
 provider=System.Data.SqlClient;
 provider connection string=&quot;data source=AAA\aaa;
      initial catalog=Database_name;
      integrated security=True;
      MultipleActiveResultSets=True;
      App=EntityFramework&quot;"
 providerName="System.Data.EntityClient" />

The error:

Server Error in '/MyApp' Application.
Line 1: Incorrect syntax near '('. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '('.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 


Stack Trace: 

[SqlException (0x80131904): Line 1: Incorrect syntax near '('.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
...

What I don't understand: where is that moment when my app use some string connection with '('? I can't install any additional programs to debug it on server and check what is wrong.

Do you have any ideas what and where could be wrong?

I Have the Following XML Packet which comes from Google.

<?xml version="1.0" encoding="UTF-8" ?> 
- <DistanceMatrixResponse>
  <status>OK</status> 
  <origin_address>Poplar Drive, Kingsbridge, Devon TQ7 1SF, UK</origin_address> 
  <destination_address>1 Saint Michaels Road, Kingsteignton, Newton Abbot, Devon TQ12 3AQ, UK</destination_address> 
- <row>
- <element>
  <status>OK</status> 
- <duration>
  <value>2710</value> 
  <text>45 mins</text> 
  </duration>
- <distance>
  <value>37958</value> 
  <text>38.0 km</text> 
  </distance>
  </element>
  </row>
  </DistanceMatrixResponse>

Now what I am trying to do is assign the two values fields to variables.

I have pulled this into a Stream IE.

Stream stream = client.OpenRead("http://ho-www/GoogleApiAccess/DistanceMatrix.aspx?origins=" + orilat + "," + orilong + "&destinations=" + destlat + "," + destlong + "&mode=driving'&units=imperial'&language=en'&sensor=false' (http://ho-www/GoogleApiAccess/DistanceMatrix.aspx?origins=" + orilat + "," + orilong + "&destinations=" + destlat + "," + destlong + "&mode=driving%27&units=imperial%27&language=en%27&sensor=false%27)");

Everything I have searched for so far only tells me how to get to the parent elements ie duration and distance but not how to get underneath.

This should be a simple answer but I just cant think it through...

Can any help put me out my misery!

I'm trying to build a report with asp.net report.

If you check this image:

enter image description here

I'm showing a table with tickets and charge. The charge column has these value:

=Fields!Charge.Value

What I want to achieve is only to show the charge value if the ticket value is not null. So as you see in the image, there are 4 tickets visible and I want to show the charge only for those four tickets not all the charges.

Any idea how we can achieve that?

I have ASP.NET MVC app which works good on my local server. When I'm deploying it into Windows Server 2008 Standard in IIS (v7.0) the app is running property (I can see panel to log in), but when I want to log in, I have such error. I have also page Contact and when I want to run it I have the same error.
I add Model.edmx using ADO.NET Entity Data Model.

The code is simple:

In controller:

private ImportEntities Entity = new ImportEntities();
public ActionResult Contact()
    {
        var dane = Entity.Contact.FirstOrDefault();
        return View("Contact",dane);
    }

Connection string in Web.config:

<add name="ImportEntities" connectionString="metadata=res://*/Models.Model.csdl|res://*/Models.Model.ssdl|res://*/Models.Model.msl;
 provider=System.Data.SqlClient;
 provider connection string=&quot;data source=AAA\aaa;
      initial catalog=Database_name;
      integrated security=True;
      MultipleActiveResultSets=True;
      App=EntityFramework&quot;"
 providerName="System.Data.EntityClient" />

The error:

Server Error in '/MyApp' Application.
Line 1: Incorrect syntax near '('. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '('.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 


Stack Trace: 

[SqlException (0x80131904): Line 1: Incorrect syntax near '('.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
...

What I don't understand: where is that moment when my app use some string connection with '('? I can't install any additional programs to debug it on server and check what is wrong.

Do you have any ideas what and where could be wrong?

I am looking for a way to add an element(Customsections), I have just found a lot of examples about how to read a specific Attribute using ConfigurationManager.GetSection, but what about adding a Section and later elements to it?

well in MSDN in this document (http://msdn.microsoft.com/en-us/library/vstudio/system.configuration.configurationsection(v=vs.100).aspx) in the examples, there is an implementation of a ConfigSection, but again nothing abou adding it programmatically.

I hope can help me I work on a new project they used a Entity framework but not has EDMX or TT files, they map tables like:

     protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new MytableMap());
MyTableMap is:
public class MyTableMap : EntityTypeConfiguration<MyTable>
    {
        public MyTableMap()
        {
            // Primary Key
            this.HasKey(t => t.table_ID);

            // Properties
            this.Property(t => t.tablepro)
                .HasMaxLength(100); ..

And I need add a SP to this project I create something like:

public virtual ObjectResult<SP1Result> SP1(string userid)
        {
            var typeParameter = userid != null ?
           new ObjectParameter("userid", userid) :
           new ObjectParameter("userid", typeof(string));

            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction< SP1Result >("SP1", typeParameter);
        }

I map the SP1Result to entity:

protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Types().Configure(t => t.MapToStoredProcedures());
     modelBuilder.Configurations.Add(new SP1Result());

But I have this issue:

The FunctionImport 'SP1' could not be found in the container 'MyContext'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The FunctionImport 'SP1 could not be found in the container 'MyContext'.

Source Error:

Line 251:           new ObjectParameter("userid", typeof(string));
Line 252:
Line 253:            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<SP1Result>("SP1", typeParameter);
Line 254:        }
Line 255:    }

I hope can you help me how add the SP to my context. Best Regards,

I am new to C# .net but i was using php. i want to achieve the same result as this

$var = $username.$jpwMobileNo;
$pass = sha1(utf8_encode($var ));

so that i can pass the $pass variable to an API that accepts String for $pass how do i achieve this. I have tried this

var pass = userName + no + time + key;
var p = Encoding.UTF8.GetBytes(pass);
var x = sha.ComputeHash(p);
var str = System.Text.Encoding.Default.GetString(x);
var user = new AWsdl.AgencyClient();
var resultAPI = user.GA(userName, no, time, key,str);

but the var str returns as a byte .how do i convert it to a string

My goal is to join two tables by specific IDs using the following within an async command.

result = (from Alpha in db.TABLE1 join Beta in db.TABLE2 on Alpha.
          where Alpha.COLUMN.Equals(query) 
          select new 
          { 
              Alpha.COUMN1, 
              Alpha.COLUMN2,
              Alpha.COLUM3, 
              Beta.COLUMN1
          });

I am getting an async issue at the select level.

My question is how do you use LINQ lambda join commands within an async controller?

I attempted to use ActionResult instead but the other controllers I am using are ASYNC and I would like to continue to use the ASYNC if at all possible.