Search Results

Search found 17 results on 1 pages for 'slauma'.

Page 1/1 | 1 

  • How to update correctly an Entity Model after changes of database structure?

    - by Slauma
    I've made some changes in the table structure and especially the relationships between tables in my SQL Server database. Now I want to update my Entity model based on this new database structure. Right clicking on the edmx file I find the option "Update model from database". But when I do this I get kind of a 50% update: The new columns appear in the Entity classes but I am confused about a lot of navigation properties which are still there in the model although the corresponding foreign key relationships do not exist anymore in the database. Am I doing something wrong? Or is there another option to update the model including deletion of navigation properties? Or do I have to delete those navigation properties manually in the model files? I am using Entity Framework Version 1 (VS 2008 SP1). Thanks for help in advance!

    Read the article

  • Serializing a list of Key/Value pairs to XML

    - by Slauma
    I have a list of key/value pairs I'd like to store in and retrieve from a XML file. So this task is similar as described here. I am trying to follow the advice in the marked answer (using a KeyValuePair and a XmlSerializer) but I don't get it working. What I have so far is a "Settings" class ... public class Settings { public int simpleValue; public List<KeyValuePair<string, int>> list; } ... an instance of this class ... Settings aSettings = new Settings(); aSettings.simpleValue = 2; aSettings.list = new List<KeyValuePair<string, int>>(); aSettings.list.Add(new KeyValuePair<string, int>("m1", 1)); aSettings.list.Add(new KeyValuePair<string, int>("m2", 2)); ... and the following code to write that instance to a XML file: XmlSerializer serializer = new XmlSerializer(typeof(Settings)); TextWriter writer = new StreamWriter("c:\\testfile.xml"); serializer.Serialize(writer, aSettings); writer.Close(); The resulting file is: <?xml version="1.0" encoding="utf-8"?> <Settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <simpleValue>2</simpleValue> <list> <KeyValuePairOfStringInt32 /> <KeyValuePairOfStringInt32 /> </list> </Settings> So neither key nor value of the pairs in my list are stored though the number of elements is correct. Obviously I am doing something basically wrong. My questions are: How can I store the key/value pairs of the list in the file? How can I change the default generated name "KeyValuePairOfStringInt32" of the elements in the list to some other name like "listElement" I'd like to have?

    Read the article

  • Strange exception when connecting to a WCF service via a proxy server

    - by Slauma
    The exception "This operation is not supported for a relative URI." occurs in the following situation: I have a WCF service: [ServiceContract(ProtectionLevel=ProtectionLevel.None)] public interface IMyService { [OperationContract] [FaultContract(typeof(MyFault))] List<MyDto> MyOperation(int param); // other operations } public class MyService : IMyService { public List<MyDto> MyOperation(int param) { // Do the business stuff and return a list of MyDto } // other implementations } MyFault and MyDto are two very simple classes marked with [DataContract] attribute and each only having three [DataMember] of type string, int and int?. This service is hosted in IIS 7.0 on a Win 2008 Server along with an ASP.NET application. I am using an SVC file MyService.svc which is located directly in the root of the web site. The service configuration in web.config is the following: <system.serviceModel> <services> <service name="MyServiceLib.MyService"> <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfig" contract="MyServiceLib.IMyService" /> </service> </services> <bindings> <wsHttpBinding> <binding name="wsHttpBindingConfig"> <security mode="None"> <transport clientCredentialType="None" /> </security> </binding> </wsHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="false"/> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> This seems to work so far as I can enter the address http://www.domain.com/MyService.svc in a browser and get the "This is a Windows Communication Foundation Service"-Welcome page. One of the clients consuming the service is a console application: MyServiceClient aChannel = new MyServiceClient("WSHttpBinding_IMyService"); List<MyDto> aMyDtoList = aChannel.MyOperation(1); It has the following configuration: <system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IMyService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="true" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="false" proxyAddress="10.20.30.40:8080" allowCookies="false"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> <security mode="None"> <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /> <message clientCredentialType="Windows" negotiateServiceCredential="true" /> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="http://www.domain.com/MyService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService" contract="MyService.IMyService" name="WSHttpBinding_IMyService" /> </client> </system.serviceModel> When I run this application at a production server at a customer site calling aChannel.MyOperation(1) throws the following exception: This operation is not supported for a relative URI. When I run this client application on my development PC with exactly the same config, with the exception that I remove proxyAddress="10.20.30.40:8080" from the bindings the operation works without problems. Now I really don't know what specifying a proxy server address might have to do with absolute or relative URIs. The use of the proxy server or not is the only difference I can see when running the client on the production or on the development machine. Does someone have an idea what this exception might mean in this context and how possibly to solve the problem? Thank you in advance for help!

    Read the article

  • Redirect from URL with QueryString to the same URL without QueryString

    - by Slauma
    I have a page request with a QueryString, say http://www.xyz.net/Orders.aspx?OrderID=1. The page is displayed in a browser. Now there is an asp:LinkButton on the page which should enable the user to open the page without the QueryString (as if he had entered http://www.xyz.net/Orders.aspx directly in the browser's address bar). I had two ideas: 1) Use the PostBackUrl attribute of the LinkButton: <asp:LinkButton ID="LinkButton1" runat="server" Text="Select" PostBackUrl="~/Orders.aspx" /> 2) Use "RedirectUrl" in an event handler: <asp:LinkButton ID="LinkButton1" runat="server" Text="Select" OnClick="LinkButton1_Click" /> ...and... protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("~/Orders.aspx"); } In both cases the browser's address bar shows http://www.xyz.net/Orders.aspx without the QueryString, as I like to have it. But in the first case the page does not change at all. But it should, because I'm evaluating the QueryString in code-behind and control the appearance of the page depending on whether a QueryString exists or not. The second option works as intended. If I am not wrong the second option requires an additional roundtrip: Browser sends request to server Event handler on server side sends Redirect URL to browser Browser sends again request to the server, but with the new URL Server sends new requested page to browser Is this correct at all? Whereas the first option omits the first two steps in the list above, thus saving the additional roundtrip and resulting in: Browser sends request to the server, but with the new URL (the PostbackURL specified in the LinkButton) Server sends new requested page to browser But, as said, the result isn't the same. I'm sure my try to explain the differences between the two options is wrong somewhere. But I don't know where exactly. Can someone explain what's really the difference? Do I really need this second roundtrip of option (2) to achieve what I want? Thanks in advance!

    Read the article

  • Browser connects to WCF service but not my WCF client. What can be the reason?

    - by Slauma
    On a production server (Windows Server 2003 SP2) I can connect to a remote WCF service with Internet Explorer 8: When I browse to the URL http://www.domain.com/Service.svc (where my service listens) I get the expected info page of the service displayed. Connection settings in Internet Explorer only specify "auto detect", proxy settings are disabled. If I start a console application (built with WCF in .NET 4.0) on the same server which also tries to connect to the same WCF service it fails telling me that no endpoint was available listening on http://www.domain.com/Service.svc. Configuration of the WCF client: <configuration> <system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IMyService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> <security mode="None"> <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /> <message clientCredentialType="Windows" negotiateServiceCredential="true"/> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="http://www.domain.com/Service.scv" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService" contract="Service.IMyService" name="WSHttpBinding_IMyService" /> </client> </system.serviceModel> <configuration> With these settings I can communicate successfully with the remote service from my development machine. Looking around for other options I found that I can specify to use the Internet Explorer proxy settings with: <system.net> <defaultProxy> <proxy usesystemdefault="true" /> </defaultProxy> </system.net> It didn't work and I am not sure if I understood this setting really correctly. (My hope was that the WCF client will adopt the "autodetect" setting of Internet Explorer and then connect the same way to the service like the installed IE.) I also had toggled the useDefaultWebProxy setting in the binding configuration between true and false with no success. Now I am asking for help what I can do? Which settings might be wrong or missing? What could I test and how can I get more detailed error messages to better identify the problem? Thank you in advance!

    Read the article

  • Binding a nullable int to an asp:TextBox

    - by Slauma
    I have a property int? MyProperty as a member in my datasource (ObjectDataSource). Can I bind this to a TextBox, like <asp:TextBox ID="MyTextBox" runat="server" Text='<%# Bind("MyProperty") %>' /> Basically I want to get a null value displayed as blank "" in the TextBox, and a number as a number. If the TextBox is blank MyProperty shall be set to null. If the TextBox has a number in it, MyProperty should be set to this number. If I try it I get an exception: "Blank is not a valid Int32". But how can I do that? How to work with nullable properties and Bind? Thanks in advance!

    Read the article

  • Project setup for an ADO.NET/WCF DataService

    - by Slauma
    I'd like to implement a ADO.NET/WCF DataService and I am wondering what's the best way to setup a project in VS2008 SP1 for this purpose. Currently I have an ASP.NET web application project (not of "WebSite" project type). The data access layer is an Entity model (EF version 1) with SQL Server database. I have the Entity Model in a separate DLL project and the web application project references to this assembly for all data accesses. The ADO.NET/WCF DataService needs to communicate with the Entity model/database as well. It has to be hosted on the same web server (IIS 7.5) together with the web application. Since the DataService is not directly related to that specific web application (though it will provide and modify data from/in the same database the web application uses as well) my basic idea was to separate the DataService in its own new project (which also references the Entity Model DLL). Now I have seen that there is no project type "ADO.NET/WCF DataService" in VS2008 SP1. It seems only possible to add a DataService as an element to other existing projects, for instance Web Application projects. Why isn't there a separate DataService project type? Does this mean now that I have to add the DataService as an element to my Web Application project? Or shall I create a new Web Application project and add a DataService to it? (I could delete the pregenerated default.aspx since I do not need any web pages in this project.) What's the best way? Thank you for suggestions in advance!

    Read the article

  • How to render a DateTime in a specific format in ASP.NET MVC 3?

    - by Slauma
    If I have in my model class a property of type DateTime how can I render it in a specific format - for example in the format which ToLongDateString() returns? I have tried this... @Html.DisplayFor(modelItem => item.MyDateTime.ToLongDateString()) ...which throws an exception because the expression must point to a property or field. And this... @{var val = item.MyDateTime.ToLongDateString(); Html.DisplayFor(modelItem => val); } ...which doesn't throw an exception, but the rendered output is empty (although val contains the expected value, as I could see in the debugger). Thanks for tips in advance! Edit ToLongDateString is only an example. What I actually want to use instead of ToLongDateString is a custom extension method of DateTime and DateTime?: public static string FormatDateTimeHideMidNight(this DateTime dateTime) { if (dateTime.TimeOfDay == TimeSpan.Zero) return dateTime.ToString("d"); else return dateTime.ToString("g"); } public static string FormatDateTimeHideMidNight(this DateTime? dateTime) { if (dateTime.HasValue) return dateTime.Value.FormatDateTimeHideMidNight(); else return ""; } So, I think I cannot use the DisplayFormat attribute and DataFormatString parameter on the ViewModel properties.

    Read the article

  • Does Security Trimming work with Web Forms Routing?

    - by Slauma
    In my web.config I have configured a SiteMapProvider with securityTrimmingEnabled="true" and on my main master page is an asp:Menu control bound to an asp:SiteMapDataSource. In addition I have configured restricted access to all pages in a subfolder "Admin" (using another web.config in this subfolder). If I put a sitemapNode in Web.sitemap... <siteMapNode url="~/Admin/Default.aspx" title="Administration" description="" > ... only users in role "Admin" will have the menu item related to that siteMapNode. So this is working fine and as intended. Now I have defined a URL route in Global.asax to map the physical file to a new URL: System.Web.Routing.RouteTable.Routes.MapPageRoute("AdminHomeRoute", "Administration/Home", "~/Admin/Default.aspx"); But when I use this route-URL in the SiteMap file... <siteMapNode url="Administration/Home" title="Administration" description="" > ... it seems that security trimming does not work: The menu item is visible for all users. (Access to the page is still restricted though, so selecting the menu item by non-Admin users does not navigate to the restricted page.) Question: Is there any setting I've missed so far to make security trimming working with URL routing in ASP.NET 4.0 Web Forms? Did I do something wrong? Is there any work-around? Thank you for help!

    Read the article

  • What am I doing wrong with HttpResponse content and headers when downloading a file?

    - by Slauma
    I want to download a PDF file from a SQL Server database which is stored in a binary column. There is a LinkButton on an aspx page. The event handler of this button looks like this: protected void LinkButtonDownload(object sender, EventArgs e) { ... byte[] aByteArray; // Read binary data from database into this ByteArray // aByteArray has the size: 55406 byte Response.ClearHeaders(); Response.ClearContent(); Response.BufferOutput = true; Response.AddHeader("Content-Disposition", "attachment; filename=" + "12345.pdf"); Response.ContentType = "application/pdf"; using (BinaryWriter aWriter = new BinaryWriter(Response.OutputStream)) { aWriter.Write(aByteArray, 0, aByteArray.Length); } } A "File Open/Save dialog" is offered in my browser. When I store this file "12345.pdf" to disk, the file has a size of 71523 Byte. The additional 16kB at the end of the PDF file are the HTML code of my page (as I can see when I view the file in an editor). I am confused because I was believing that ClearContent and ClearHeaders would ensure that the page content is not sent together with the file content. What am I doing wrong here? Thanks for help!

    Read the article

  • How to define a "complicated" ComputedColumn in SQL Server?

    - by Slauma
    SQL Server Beginner question: I'm trying to introduce a computed column in SQL Server (2008). In the table designer of SQL Server Management Studio I can do this, but the designer only offers me one single edit cell to define the expression for this column. Since my computed column will be rather complicated (depending on several database fields and with some case differentiations) I'd like to have a more comfortable and maintainable way to enter the column definition (including line breaks for formatting and so on). I've seen there is an option to define functions in SQL Server (scalar value or table value functions). Is it perhaps better to define such a function and use this function as the column specification? And what kind of function (scalar value, table value)? To make a simplified example: I have two database columns: DateTime1 (smalldatetime, NULL) DateTime2 (smalldatetime, NULL) Now I want to define a computed column "Status" which can have four possible values. In Dummy language: if (DateTime1 IS NULL and DateTime2 IS NULL) set Status = 0 else if (DateTime1 IS NULL and DateTime2 IS NOT NULL) set Status = 1 else if (DateTime1 IS NOT NULL and DateTime2 IS NULL) set Status = 2 else set Status = 3 Ideally I would like to have a function GetStatus() which can access the different column values of the table row which I want to compute the value of "Status" for, and then only define the computed column specification as GetStatus() without parameters. Is that possible at all? Or what is the best way to work with "complicated" computed column definitions? Thank you for tips in advance!

    Read the article

  • How to clear all form fields from code-behind?

    - by Slauma
    HTML has an input button type to reset all fields in a form to their initial state in one step: <input type="reset" ... />. Is there a similar simple way to reset all form fields of an aspx page from code-behind? Or is it necessary to reset all controls one by one with TextBox1.Text=string.Empty, TextBox2.Text=string.Empty, etc. ? Thanks in advance!

    Read the article

  • How can I prevent a page to jump to top position after failed validation?

    - by Slauma
    I have a simple aspx page with a few TextBoxes and a submit button. Some fields are required and below the button is a ValidationSummary. The complete form is larger than screen height so one has to scroll down to reach the submit button. If I don't fill all required fields and click on submit validation fails as expected and the validation summary displays some info messages below the button. Validation happens on the client and no postback occurs. So this all works as wished. But disturbing is that the page moves ("jumps") to top position when I click on the submit button. To see the validation summary one has to move down the page again. I've tried to set the ShowSummary property to false (which doesn't make much sense): The validation still works (no postback) but in this case the page does not move to top position. So the problem seems to depend on rendering the validation texts. Is there a way to prevent this page jump? Thank you in advance!

    Read the article

  • How do I initialize the controls in an InsertItemTemplate?

    - by Slauma
    I have - for instance - an asp:FormView which supports Read, Insert, Update, Delete and is bound to a DataSource: <asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource1" > <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("MyText") %>' /> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("MyText") %>' /> </EditItemTemplate> <InsertItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("MyText") %>' /> </InsertItemTemplate> </asp:FormView> If I am in Read-Mode or Edit-Mode the control is initialized with the property MyText of the current object which is bound to the FormView. But when I go to Insert-Mode I do not have a "current object" (FormView1.DataItem is indeed null) and the controls are empty. If I want to have my TextBox control initialized with a specific value how can I do that? In which event can I hook in to set default values to the controls in the InsertItemTemplate? Especially I have in mind using an ObjectDataSource. I was expecting that the InsertItemTemplate is initialized with a business object which underlies my ObjectDataSource and which is created by the ASP.NET framework simply by using its default constructor when the InsertItemTemplate gets activated. In the default constructor I would init the class members to the default values I'd like to have in my controls of the InsertItemTemplate. But unfortunately that's not the case: No "default" object is created and bound to the FormView. So it seems I have to initialize all controls separately or to create the default object manually and bind it to the InsertItemTemplate of the FormView. But how and where can I do that? Thanks in advance!

    Read the article

  • Creating an appropriate index for a frequently used query in SQL Server

    - by Slauma
    In my application I have two queries which will be quite frequently used. The Where clauses of these queries are the following: WHERE FieldA = @P1 AND (FieldB = @P2 OR FieldC = @P2) and WHERE FieldA = @P1 AND FieldB = @P2 P1 and P2 are parameters entered in the UI or coming from external datasources. FieldA is an int and highly on-unique, means: only two, three, four different values in a table with say 20000 rows FieldB is a varchar(20) and is "almost" unique, there will be only very few rows where FieldB might have the same value FieldC is a varchar(15) and also highly distinct, but not as much as FieldB FieldA and FieldB together are unique (but do not form my primary key, which is a simple auto-incrementing identity column with a clustered index) I'm wondering now what's the best way to define an index to speed up specifically these two queries. Shall I define one index with... FieldB (or better FieldC here?) FieldC (or better FieldB here?) FieldA ... or better two indices: FieldB FieldA and FieldC FieldA Or are there even other and better options? What's the best way and why? Thank you for suggestions in advance!

    Read the article

  • How to create a fully qualified hyperlink to a resource dynamically?

    - by Slauma
    In ASP.NET I'd like to create a link which points to a specific Uri and send this link in an email to a user, for instance something like http://www.BlaBla.com/CustomerPortal/Order/9876. I can create the second part of the Uri /CustomerPortal/Order/9876 dynamically in code-behind. My question is: How can I create the base Uri http://www.BlaBla.com without hardcoding it in my application? Basically I want to have something like: http://localhost:1234/CustomerPortal/Order/9876 (on my development machine) http://testserver/CustomerPortal/Order/9876 (on an internal test server) http://www.BlaBla.com/CustomerPortal/Order/9876 (on the production server) So is there a way to ask the server where the application is running: "Please tell me the base Uri of the application" ? Or any other way? Thank you in advance!

    Read the article

  • <%: %> brackets for HTML Encoding in ASP.NET 4.0

    - by Slauma
    Accidentally I found this post about a new feature in ASP.NET 4.0: Expressions enclosed in these new brackets <%: Content %> should be rendered as HTML encoded. I've tried this within a databound label in a FormView like so: <asp:Label ID="MyLabel" runat="server" Text='<%: Eval("MyTextProperty") %>' /> But it doesn't work: The text property contains script tags (for testing), but the output is blank. Using the traditional way works: <asp:Label ID="MyLabel" runat="server" Text='<%# HttpUtility.HtmlEncode(Eval("MyTextProperty")) %>' /> What am I doing wrong? (On a sidenote: I am too stupid to find any information: Google refuses to search for that thing. The VS2010 Online help on MSDN offers a lot of hits, but nothing related to my search. Stackoverflow search too. And I don't know how these "things" (the brackets I mean) are officially called to have a better search term.) Any info and additional links and resources are welcome! Thanks in advance!

    Read the article

1