|
I'm just curious when I grab a connection string from my Web.config file using, say, WebConfigurationManager...
string connectionString = WebConfigurationManager.ConnectionStrings["myDatabase"];
...is the xml from the web.config file being read and parsed each and everytime this method is called? Or does is load the web.config and all it's settings into memory?
If it is reading the file each time, would it be faster to place the connection string into the Application Cache and read it from there?
Cheers!
Sunday Ironfoot
www.dominicpettifer.co.uk (work in progress)
|
|
|
|
|
Yes you are right,web.config is parsed each and everytime and your method will be called.This will show impact on performance so you can use cache memory to hold the connecton string.
Dont forget to set the expiry policy for that cache item,
i prefer file based expiry policy so that when web.config is changed then cache item get refreshed.
|
|
|
|
|
Interesting, if it is parsing the xml file each time it's doing it really quickly, far more efficiently than I thought. For instance if I do something like the follow code...
for (int i = 0; i < 1000; i++)
{
connectionString =
WebConfigurationManager.ConnectionStrings["default"].ConnectionString;
}
...it's going to parse the xml file 1000 times and cause the page execution to hang for a bit, except my page execution time is about 0.015 seconds. Also if I add a Thread.Sleep(1) inside the for loop the page execution jumps to about 2 seconds (1 second for Thread.Sleep(1) x 1000 plus any overhead from Thread.Sleep() method) meaning it's not my page timer thats not timing properly or anything.
Are you sure it's reading the web.config file each time and not just reading the settings from memory? Or have I way overestimated the overhead of parsing through xml?
Sunday Ironfoot
www.dominicpettifer.co.uk (work in progress)
|
|
|
|
|
So I have a very simple webpage (see below). When I click on the first button it posts back and updates the value with in the text box just fine, and same with the second one. But if I click on the first button then immediately click on the second one, so that they are both posting back at the same time, it will come back and fill in the data for the firs textbox, after the Thread.Sleep() has completed, then it will blow out the value in the first textbox, and set the value for the second value.
So it looks like it grabs the currect viewstate of all of the controls that have "AutoUpdateAfterCallBack" turned on, and there for when the callback is complete it will reset all of the fields, then update the value(s) that you wanted set.
Does anyone know how to get this example to work properly with the latest version of Anthem.Net? I only want it to update the fields that I actually modified with in the server side code.
[HTML Code]
<form id="form1" runat="server">
<div>
<anthem:TextBox ID="txt1" runat="server" EnableCallBack="true" AutoUpdateAfterCallBack="True"></anthem:TextBox>
<anthem:Button ID="btn1" runat="server" Text="Ajax w/Sleep" EnableCallBack="true" TextDuringCallBack="Processing..." EnabledDuringCallBack="false" />
</div>
<div>
<anthem:TextBox ID="txt2" runat="server" EnableCallBack="true" AutoUpdateAfterCallBack="True"></anthem:TextBox>
<anthem:Button ID="btn2" runat="server" Text="Ajax w/Sleep" EnableCallBack="true" TextDuringCallBack="Processing..." EnabledDuringCallBack="false" />
</div>
</form>
[Code Behind]
Partial Class Default
Inherits System.Web.UI.Page
Protected Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
txt1.Text = "Hello World"
Threading.Thread.Sleep(1000)
End Sub
Protected Sub btn2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn2.Click
txt2.Text = "Hello World"
Threading.Thread.Sleep(1000)
End Sub
End Class
-- modified at 18:43 Thursday 14th September, 2006
I'm using Anthem.Net v1.3.2 with VS.Net 2005 Pro.
|
|
|
|
|
For anyone that is interested, I found the solution to my problem.
Instead of setting the "AutoUpdateAfterCallBack" property in the HTML code, you would instead set it after you've updated the value for the text field, for example:
Partial Class Default
Inherits System.Web.UI.Page
Protected Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
txt1.Text = "Hello World"
txt1.UpdateAfterCallBack = True
Threading.Thread.Sleep(1000)
End Sub
Protected Sub btn2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn2.Click
txt2.Text = "Hello World"
txt2.UpdateAfterCallBack = True
Threading.Thread.Sleep(1000)
End Sub
End Class
That way the auto updating functionality of Anthem.Net will only update the specific field(s) that you set to update after the callback has occured.
|
|
|
|
|
I am using PUSH method to view data by crystal report. but i trying to export data in any format (i.e PDF) then i m getting error .. Logon fail
i dont know why this is happening ..
any suggestion please
thanks in advance
|
|
|
|
|
Imports System.Web.Services
<WebService("http://www.FL.com/SimpleHelloWorld/", "A simple web service which display message.")> _
Public Class HelloWorld
Code here
End Class
Getting error
c:\inetpub\wwwroot\WebService1\HelloWorld.asmx.vb(2): Attribute specifier is not a complete statement. Use a line continuation to apply the attribute to the following statement.
But i place underscore....
Amit
|
|
|
|
|
Maybe it's the line between the attribute and the class declaration.
Another thing I see, it's an illegal character that is not visible in the designer, try to delete and retype it to see if there is any change.
|
|
|
|
|
<WebService(Namespace="http://www.FL.com/SimpleHelloWorld/", Description="A simple web service which display message.")> _
.....
Hope this helps.
|
|
|
|
|
Kumar, removing the blank line after <webservice(namespace="http: www.fl.com="" simplehelloworld="" ",="" description="A simple web service which display message." )=""> _ will hopefully solve your problem.
|
|
|
|
|
Is Cache class available to App_Code folder too.
Because in my Global.cs which resides in App_code, If i use Cache["test" = "testvalue"; am getting a compiler error saying 'System.Web.Caching.Cache' is a 'type' but is used like a 'variable'
can anyone help
|
|
|
|
|
Context.Cache["test"] = "testvalue";
only two letters away from being an asset
|
|
|
|
|
Hey Guys
It is almost more than year I am working on dot.net, but unfortunately I never get the chance to work on hot technology like web service…
I am planning to learn myself so please suggest some good sites from where I can start. Specially with SOAP model…..I search some sites and maximum are for intermediate level…
Please suggest some good links from where I can get good exposure for web service with SOAP
Amit
|
|
|
|
|
|
|
hi guys i just wanna ask some question about the database my asp is connected to.
i now have a ms excel form whihc have over 900++ records !!!!
i am trying to find if there is a way to convert the excel database into my sql database.
pls suggest or tell me how i can do this.
i really dont want to type out 900++ records haha >.<
|
|
|
|
|
use DTS or BCP or import utility. All come with sql server....
Amit
|
|
|
|
|
Hi!
Does any one knows of any toolbar web part, this toolbar will contain a list of web sites and sub sites. I need to hook this sort of web part into my share point portal.
Your help is highly appreciated.
Thank you.
happy coding!
|
|
|
|
|
hi all
the question is more related to architecture and practices and I'll appreciate any opinion
i work with asp net 1/2 few years and with any project we developing we meet performance issues
maybe the problems is our methods or maybe we do not do the right things but it seems that view state and heavy page model really make performance bad
also, when you work with asp.net it very easy to start building your site component-oriented with many levels of nested controls that every one is data-driven and make a db call that altogether cause bad database performance
we recently did code review for other companies products and i see that every-one do that mistake with component-oriented design cause it so simple and fun to make smart controls with public properties and reuse them everywhere
also, i did a production application with MonoRail (MVS framework based on asp.net but using different light page-model and no viewstate) and it just lot faster
i will welcome any examples of how you guys build ASP.Net site that fast and easy to scale, also, any links to good resources are welcome
if you suggest to switch to PHP or Ruby on Rails i promise to consider that
Thanks much
EV
and may the source be with you
|
|
|
|
|
There is nothing wrong with the ASP.NET architecture.
As with every powerful tool you have to keep an eye on what's happening, or it can really get messy.
The Web controls that come with ASP.NET is convenient for easily putting together a working form, but the view state easily grows quite a bit. The view state can be disabled for controls where you don't need it, or you might consider using the Html controls instead. You have to do more of the work yourself, but it still is no more work than if the Web controls didn't exist at all. If a Web control give you more thouble than it's worth, just don't use it.
If you have a lot of components in a page that is performance critical, they shouldn't be database driven, they should be data bound. That means that you still feed them the data from the page, they don't fetch it themselves.
---
b { font-weight: normal; }
|
|
|
|
|
agree with you that it easy to get messy with powerful tools
but it seems to me that switching viewstate on/off and keeping an eye with on components to use data access smartly is just non enough to make an application to perform fine
what i really want to find is practices and guidelines to build performance-oriented applications ,
there is a lot of articles with tips like :
- use stored procedures
- prevent round-trips to database
- disable view state where you do not needed etc
etc...
but with all the googling i cant find something more about strategy and architecture of scalable and fast application
Thanks for your reply
|
|
|
|
|
If you're having performance problems have you tried implementing Caching. ASP.NET from what I can gather has very powerful Caching capabilities.
For instance, you can cache the raw HTML output from the aspx page for a certain duration (10 mins say) so that the page is only being drawn every 10 mins, requests in between are just grabbing the raw HTML output will no database access etc. It's also possible to cache different versions of the same page based on a querystring parameter say (eg. showProducts.aspx?productID=5 ).
Also set Cache dependancies (data expires on certain conditions - database change etc), set timeouts, set delegates that fire when Cache is removed etc. There's loads of stuff you go do with it, too much to list here.
The Cache object can be accessed from almost anywhere it seems, Cache propety from an ASPX page, Context.Cache from the Global.asax, or from the HostingEnvironment class (ASP.NET 2.0 only) from anywhere else, making it extreme flexible to use.
Sunday Ironfoot
www.dominicpettifer.co.uk (work in progress)
|
|
|
|
|
Caching with asp.net is fun, but i actually looking for methods to write fast sites without uing of cache. you always can add caching on optimization phase but it can't help you everywhere when your site is higly personalized and each page is different according to user logged in
Thanks for your reply
and may the source be with you
|
|
|
|
|
We are upgrading our intranet's main page from classic asp to .Net 2.0. Currently there are all three type of web apps on the server, .Net 2.0, 1.1 & asp. The asp classic main page currently uses techniques similar to http://www.eggheadcafe.com/articles/20021207.asp which has worked for a couple of years now. Now we are upgrading the main page to .Net 2.0 and I am having problems finding any solution that works, much less an elegant one that will require minimal change throughout the applications.
Currently I have tried the following with out success:
http://www.asp101.com/articles/sidney/sharingsessionstate/default.asp[^]
which should work and possibly does using .Net 1.1 but not with .Net 2.0.
Microsoft solution, http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/converttoaspnet.asp[^], fails to work in .Net 2.0 either.
I glanced at this one http://searchvb.techtarget.com/tip/1,289483,sid8_gci951935,00.html[^] but I think it would have the same issue as the previous ones.
With the asp101 & Microsoft's solution, I am unable to transfer any session information from any .Net 2.0 app to another .Net 2.0 or .Net 1.1 app. I am not sure why. I think it might be because I am running on XP and there is no option for application pooling in IIS. I know in IIS on server 2003 you have to create a new pool for .Net 2.0 apps. The actual Session will transfer with both techniques it is just getting the session to the intermediate page, SessionTransfer.aspx.
Process Flow:
ASP.Net page => SessionTransfer.aspx => SessionTransfer.asp => asp page
The trouble I am finding is the ASP.Net to the SessionTransfer.aspx page. The Session.Count value in the SessionTransfer.aspx page is 0.
Any help or link would be much appreciated and resolving this Session issue.
Thanks,
Michael
I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious.
Vince Lombardi (1913-1970)
|
|
|
|
|
What is wrong with this Regex for e-mail?Thank you
Regex emailRegex=new Regex(@"^*@*.*$");
|
|
|
|