Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - matweb.com: How to get source of page? -


i have url like:
http://www.matweb.com/search/datasheet.aspx?matguid=849e2916ab1541be9ff6a17b78f95c82

i want download source code page using code:

private static string urltemplate = @"http://www.matweb.com/search/datasheet.aspx?matguid=";  static string getsource(string guid) {     try     {         uri url = new uri(urltemplate + guid);          httpwebrequest webrequest = (httpwebrequest)webrequest.create(url);         webrequest.method = "get";                         httpwebresponse webresponse = (httpwebresponse)webrequest.getresponse();          stream responsestream = webresponse.getresponsestream();         streamreader responsestreamreader = new streamreader(responsestream);         string result = responsestreamreader.readtoend();          return result;     }     catch (exception ex)     {         return null;     } } 

when get:

you not seem have cookies enabled. matweb requires cookies enabled.

ok, understand, added lines:

cookiecontainer cc = new cookiecontainer();   webrequest.cookiecontainer = cc;  

i got:

your ip address has been restricted due excessive use. problem may compounded when ip address may shared many people in company or through internet service provider. apologize inconvenience.

i can understand i'm not getting message when try visit page using web browser. can source code? cookies or http headers?

it doesn't useragent. try this:

webrequest.useragent = "mozilla/5.0 (windows; u; windows nt 6.1; en-us; rv:1.9.2.13) gecko/20101203 firefox/3.6.13 (.net clr 3.5.30729)"; //maybe substitute own in here 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -